From c13add1edeb87395cb460c0103ae3e5b610f0d78 Mon Sep 17 00:00:00 2001 From: Jeremy Kuhne Date: Thu, 20 Jul 2023 16:37:36 -0700 Subject: [PATCH 001/231] Cleanup for utilization of target new (#9527) Tweaks the editor config settings to encourage behavior that matches our coding style: - We prefer `Foo foo = new()` over `var foo =`. - `var` for built in types is an error - Expression bodied members are always ok A number of the rules got added by just using the editor. I'll continue to iterate. Changed a big chunk of the code to use target typed new using fixers and regexe's for the majority of the changes. --- .editorconfig | 52 +++- docs/testing.md | 12 +- .../TestUtilities/BinarySerialization.cs | 12 +- .../tests/TestUtilities/DebuggerAttributes.cs | 2 +- .../InteractionTests.cs | 2 +- .../WindowsFormsApplicationBaseTests.cs | 4 +- .../Internal/ProgressDialogTests.cs | 4 +- .../VisualBasicRuntimeTest/Program.cs | 8 +- .../SingleInstanceTests.cs | 2 +- .../src/Interop/Windows/Gdi32/Interop.RECT.cs | 2 +- .../src/System/Drawing/Bitmap.cs | 4 +- .../src/System/Drawing/Brushes.cs | 284 +++++++++--------- .../Drawing/Drawing2D/LinearGradientBrush.cs | 8 +- .../Drawing2D/SafeCustomLineCapHandle.cs | 2 +- .../System/Drawing/DrawingCom.ComWrappers.cs | 4 +- .../src/System/Drawing/FontFamily.cs | 8 +- .../src/System/Drawing/Graphics.cs | 2 +- .../src/System/Drawing/Icon.ComWrappers.cs | 2 +- .../src/System/Drawing/Image.cs | 2 +- .../src/System/Drawing/ImageAnimator.cs | 2 +- .../src/System/Drawing/Imaging/Encoder.cs | 26 +- .../Drawing/Imaging/EncoderParameter.cs | 2 +- .../System/Drawing/Imaging/FrameDimension.cs | 6 +- .../System/Drawing/Imaging/ImageAttributes.cs | 2 +- .../src/System/Drawing/Imaging/ImageFormat.cs | 24 +- .../Drawing/Imaging/MetafileHeaderWmf.cs | 2 +- .../Drawing/Internal/SystemColorTracker.cs | 2 +- .../src/System/Drawing/NativeMethods.cs | 2 +- .../src/System/Drawing/Pens.cs | 282 ++++++++--------- .../System/Drawing/Printing/PageSettings.cs | 2 +- .../Printing/PreviewPrintController.cs | 2 +- .../System/Drawing/Printing/PrintDocument.cs | 2 +- .../src/System/Drawing/Printing/TriState.cs | 6 +- .../System/Drawing/PropertyItemInternal.cs | 2 +- .../src/System/Drawing/ScreenDC.cs | 2 +- .../src/System/Drawing/SystemBrushes.cs | 2 +- .../src/System/Drawing/SystemPens.cs | 2 +- .../System/Drawing/ToolboxBitmapAttribute.cs | 6 +- src/System.Drawing.Common/src/misc/DbgUtil.cs | 4 +- .../tests/BitmapTests.cs | 2 +- .../tests/Drawing2D/MatrixTests.cs | 2 +- .../tests/Drawing2D/PathGradientBrushTests.cs | 2 +- src/System.Drawing.Common/tests/ImageTests.cs | 4 +- .../tests/Imaging/ImageAttributesTests.cs | 8 +- .../tests/Imaging/ImageFormatTests.cs | 26 +- .../tests/Imaging/MetafileTests.cs | 4 +- .../tests/Printing/PrintDocumentTests.cs | 2 +- .../System/Drawing/FontConverterTests.cs | 4 +- .../tests/ToolboxBitmapAttributeTests.cs | 2 +- .../ComponentModel/Design/ByteViewer.cs | 4 +- .../Design/DesignSurfaceManager.cs | 2 +- .../Design/DesignerActionPanel.HeaderLine.cs | 2 +- .../DesignerActionPanel.SeparatorLine.cs | 2 +- .../Design/DesignerActionPanel.cs | 4 +- .../ComponentModel/Design/DesignerActionUI.cs | 4 +- .../Design/DesignerEventService.cs | 8 +- .../ComponentModel/Design/DesignerHost.cs | 32 +- .../Design/InheritanceService.cs | 2 +- .../Design/InheritedPropertyDescriptor.cs | 2 +- .../Design/MenuCommandService.cs | 2 +- .../ComponentModel/Design/SelectionService.cs | 4 +- .../CodeDomComponentSerializationService.cs | 8 +- .../Serialization/CodeDomDesignerLoader.cs | 2 +- .../Design/Serialization/CodeDomSerializer.cs | 2 +- .../Serialization/CodeDomSerializerBase.cs | 2 +- .../ComponentTypeCodeDomSerializer.cs | 2 +- .../EventMemberCodeDomSerializer.cs | 2 +- ...Serializer.SerializationResourceManager.cs | 2 +- .../Serialization/TypeCodeDomSerializer.cs | 4 +- .../ComponentModel/Design/UndoEngine.cs | 4 +- .../src/System/Drawing/Design/BitmapEditor.cs | 2 +- .../src/System/Drawing/Design/IconEditor.cs | 2 +- .../src/System/Drawing/Design/ToolboxItem.cs | 2 +- .../Forms/Design/AnchorEditor.AnchorUI.cs | 4 +- .../Behavior/BehaviorService.AdornerWindow.cs | 17 +- .../BehaviorService.MenuCommandHandler.cs | 2 +- .../Forms/Design/Behavior/BehaviorService.cs | 2 +- .../DesignerActionKeyboardBehavior.cs | 2 +- .../Design/Behavior/DragAssistanceManager.cs | 2 +- .../Windows/Forms/Design/ComponentTray.cs | 15 +- .../Windows/Forms/Design/ControlDesigner.cs | 6 +- .../Windows/Forms/Design/DesignerOptions.cs | 2 +- .../Design/DesignerToolStripControlHost.cs | 2 +- .../Windows/Forms/Design/DocumentDesigner.cs | 4 +- .../Forms/Design/EventHandlerService.cs | 2 +- .../Windows/Forms/Design/FormatControl.cs | 2 +- .../Forms/Design/ItemTypeToolStripMenuItem.cs | 2 +- .../Forms/Design/MaskDesignerDialog.cs | 2 +- .../Windows/Forms/Design/MenuCommands.cs | 78 ++--- .../Forms/Design/OleDragDropHandler.cs | 2 +- .../Forms/Design/ParentControlDesigner.cs | 2 +- .../Forms/Design/SelectionUIHandler.cs | 6 +- .../Forms/Design/SelectionUIService.cs | 4 +- ...ContainerDesigner.OrientationActionList.cs | 2 +- .../Forms/Design/SplitContainerDesigner.cs | 2 +- .../Windows/Forms/Design/ToolStripDesigner.cs | 4 +- .../Design/DesignerHostTests.cs | 8 +- .../Design/DataMemberFieldConverterTests.cs | 2 +- .../src/Interop/Interop.ARGB.cs | 2 +- .../src/Interop/Interop.POINTS.cs | 2 +- .../src/Interop/OleAut32/Interop.VARIANT.cs | 2 +- .../Shell/ICategorizeProperties.cs | 2 +- .../Shell/IProvidePropertyBuilder.cs | 2 +- .../Shell/IVSMDPerPropertyBrowsing.cs | 2 +- .../Shell/IVsPerPropertyBrowsing.cs | 2 +- .../src/System/EasyPoint.cs | 6 +- .../Forms/Automation/UiaTextProvider.cs | 2 +- .../Windows/Forms/DeviceContextExtensions.cs | 2 +- .../Forms/Internals/UnicodeCharBuffer.cs | 2 +- .../Forms/Internals/WeakRefCollection.cs | 2 +- .../src/System/Windows/Forms/Padding.cs | 4 +- .../System/Windows/Forms/RefCountedCache.cs | 2 +- .../System/Windows/Forms/SinglyLinkedList.cs | 2 +- .../Windows/Forms/SystemDrawingExtensions.cs | 2 +- .../src/Windows/Win32/GetDcScope.cs | 2 +- .../src/Windows/Win32/PInvoke.LCID.cs | 4 +- .../Win32/PInvoke.SelectPaletteScope.cs | 2 +- .../tests/TestUtilities/DeviceContextState.cs | 2 +- .../tests/TestUtilities/Metafiles/EmfScope.cs | 2 +- .../tests/TestUtilities/NoAssertContext.cs | 6 +- .../PlatformDetection.Windows.cs | 2 +- .../tests/TestUtilities/PlatformDetection.cs | 4 +- .../UnitTests/Interop/GdiPlus/ARGBTests.cs | 2 +- .../Interop/Richedit/CHARFORMAT2WTests.cs | 2 +- .../Interop/User32/GetWindowTextTests.cs | 2 +- .../TestAccessors.UiaTextRangeTestAccessor.cs | 2 +- .../System/Resources/ResXResourceReader.cs | 4 +- .../System/Resources/ResXResourceWriter.cs | 2 +- .../Forms/AccessibleRoleControlTypeMap.cs | 2 +- .../System/Windows/Forms/ArrangedElement.cs | 2 +- .../src/System/Windows/Forms/AxHost.cs | 4 +- .../src/System/Windows/Forms/Binding.cs | 27 +- .../src/System/Windows/Forms/BindingSource.cs | 20 +- .../Windows/Forms/BindingsCollection.cs | 6 +- .../src/System/Windows/Forms/Button.cs | 2 +- .../src/System/Windows/Forms/ButtonBase.cs | 4 +- .../ButtonBaseAdapter.ColorOptions.cs | 2 +- .../ButtonBaseAdapter.LayoutOptions.cs | 4 +- .../Forms/ButtonInternal/ButtonBaseAdapter.cs | 31 +- .../ButtonInternal/ButtonStandardAdapter.cs | 2 +- .../ButtonInternal/CheckBoxBaseAdapter.cs | 8 +- .../ButtonInternal/CheckBoxStandardAdapter.cs | 2 +- .../CheckableControlBaseAdapter.cs | 2 +- .../ButtonInternal/RadioButtonBaseAdapter.cs | 2 +- .../System/Windows/Forms/ButtonRenderer.cs | 2 +- .../src/System/Windows/Forms/CheckBox.cs | 8 +- .../System/Windows/Forms/CheckBoxRenderer.cs | 4 +- .../System/Windows/Forms/CheckedListBox.cs | 2 +- .../src/System/Windows/Forms/ColorDialog.cs | 2 +- .../src/System/Windows/Forms/ComboBox.cs | 24 +- .../System/Windows/Forms/ComboBoxRenderer.cs | 2 +- .../src/System/Windows/Forms/Command.cs | 2 +- .../COM2IManagedPerPropertyBrowsingHandler.cs | 2 +- .../COM2Interop/COM2TypeInfoProcessor.cs | 8 +- .../ComNativeDescriptor.ComTypeDescriptor.cs | 4 +- .../System/Windows/Forms/ContainerControl.cs | 4 +- .../Windows/Forms/Control.ActiveXImpl.cs | 6 +- .../Forms/Control.ThreadMethodEntry.cs | 2 +- .../src/System/Windows/Forms/Control.cs | 158 +++++----- .../Forms/ControlBindingsCollection.cs | 2 +- .../src/System/Windows/Forms/ControlPaint.cs | 34 +-- .../System/Windows/Forms/CurrencyManager.cs | 2 +- .../src/System/Windows/Forms/Cursor.cs | 2 +- .../src/System/Windows/Forms/DataFormats.cs | 2 +- .../Windows/Forms/DataGridView.HitTestInfo.cs | 2 +- .../Windows/Forms/DataGridView.Methods.cs | 6 +- .../src/System/Windows/Forms/DataGridView.cs | 240 +++++++-------- .../Windows/Forms/DataGridViewButtonCell.cs | 2 +- .../System/Windows/Forms/DataGridViewCell.cs | 21 +- .../Windows/Forms/DataGridViewCellStyle.cs | 2 +- .../Windows/Forms/DataGridViewCheckBoxCell.cs | 2 +- .../Forms/DataGridViewColumnCollection.cs | 2 +- .../Forms/DataGridViewColumnHeaderCell.cs | 6 +- .../Windows/Forms/DataGridViewComboBoxCell.cs | 2 +- .../Windows/Forms/DataGridViewHeaderCell.cs | 2 +- .../System/Windows/Forms/DataGridViewRow.cs | 6 +- .../DataGridViewRowCollection.RowComparer.cs | 2 +- .../Forms/DataGridViewRowHeaderCell.cs | 6 +- .../Windows/Forms/DataObject.DataStore.cs | 2 +- .../Forms/DataObject.FormatEnumerator.cs | 2 +- .../Windows/Forms/DataStreamFromComStream.cs | 4 +- .../System/Windows/Forms/DateTimePicker.cs | 6 +- .../ComponentEditorForm.PageSelector.cs | 4 +- .../Forms/Design/ComponentEditorForm.cs | 2 +- ...lStripItemDesignerAvailabilityAttribute.cs | 2 +- .../System/Windows/Forms/DockingAttribute.cs | 2 +- .../DrawListViewColumnHeaderEventArgs.cs | 2 +- .../Forms/ErrorProvider.ErrorWindow.cs | 19 +- .../src/System/Windows/Forms/ErrorProvider.cs | 3 +- .../Windows/Forms/FolderBrowserDialog.cs | 2 +- .../src/System/Windows/Forms/FontDialog.cs | 4 +- .../src/System/Windows/Forms/Form.cs | 62 ++-- .../System/Windows/Forms/FormCollection.cs | 2 +- .../src/System/Windows/Forms/Formatter.cs | 2 +- .../src/System/Windows/Forms/GroupBox.cs | 6 +- .../System/Windows/Forms/GroupBoxRenderer.cs | 2 +- .../src/System/Windows/Forms/HScrollBar.cs | 2 +- .../src/System/Windows/Forms/Help.cs | 8 +- .../Windows/Forms/HtmlElementEventArgs.cs | 6 +- .../Forms/ImageList.ImageCollection.cs | 18 +- .../Forms/ImageList.NativeImageList.cs | 2 +- .../src/System/Windows/Forms/ImageList.cs | 4 +- .../System/Windows/Forms/ImageListStreamer.cs | 2 +- .../src/System/Windows/Forms/InputLanguage.cs | 4 +- .../Windows/Forms/Internal/Gdi/FontCache.cs | 2 +- .../Windows/Forms/Internal/Gdi/GdiCache.cs | 2 +- .../src/System/Windows/Forms/KeysConverter.cs | 4 +- .../src/System/Windows/Forms/Label.cs | 8 +- .../Forms/Layout/ArrangedElementCollection.cs | 4 +- .../Windows/Forms/Layout/CommonProperties.cs | 8 +- .../Windows/Forms/Layout/DefaultLayout.cs | 2 +- .../System/Windows/Forms/Layout/FlowLayout.cs | 2 +- .../Layout/TableLayout.ColumnSpanComparer.cs | 2 +- .../Forms/Layout/TableLayout.LayoutInfo.cs | 4 +- .../Forms/Layout/TableLayout.MaxSizeProxy.cs | 2 +- .../Forms/Layout/TableLayout.MinSizeProxy.cs | 2 +- ...ableLayout.PostAssignedPositionComparer.cs | 2 +- ...TableLayout.PreAssignedPositionComparer.cs | 2 +- .../Layout/TableLayout.RowSpanComparer.cs | 2 +- .../Windows/Forms/Layout/TableLayout.cs | 2 +- .../src/System/Windows/Forms/LinkLabel.cs | 10 +- .../src/System/Windows/Forms/ListBox.cs | 10 +- .../src/System/Windows/Forms/ListControl.cs | 18 +- .../ListView.ListViewNativeItemCollection.cs | 2 +- .../src/System/Windows/Forms/ListView.cs | 116 +++---- ...ViewGroup.ListViewGroupAccessibleObject.cs | 2 +- .../Windows/Forms/ListViewGroupConverter.cs | 2 +- .../Windows/Forms/ListViewInsertionMark.cs | 10 +- .../src/System/Windows/Forms/ListViewItem.cs | 12 +- .../Forms/ListViewLabelEditUiaTextProvider.cs | 6 +- .../src/System/Windows/Forms/MDIClient.cs | 4 +- .../src/System/Windows/Forms/MaskedTextBox.cs | 10 +- .../src/System/Windows/Forms/MenuStrip.cs | 4 +- .../src/System/Windows/Forms/MenuTimer.cs | 2 +- ...Calendar.CalendarButtonAccessibleObject.cs | 2 +- .../src/System/Windows/Forms/MonthCalendar.cs | 10 +- .../System/Windows/Forms/MouseHoverTimer.cs | 2 +- .../Windows/Forms/NativeWindow.WindowClass.cs | 2 +- .../src/System/Windows/Forms/NotifyIcon.cs | 28 +- .../src/System/Windows/Forms/OSFeature.cs | 4 +- .../Windows/Forms/OwnerDrawPropertyBag.cs | 4 +- .../src/System/Windows/Forms/Panel.cs | 4 +- .../src/System/Windows/Forms/PictureBox.cs | 10 +- .../Forms/Printing/PrintPreviewControl.cs | 11 +- .../src/System/Windows/Forms/ProgressBar.cs | 2 +- .../src/System/Windows/Forms/PropertyGrid.cs | 12 +- .../PropertyGridInternal/DropDownButton.cs | 4 +- .../Forms/PropertyGridInternal/GridEntry.cs | 4 +- ...idView.PropertyGridViewAccessibleObject.cs | 2 +- .../PropertyGridInternal/PropertyGridView.cs | 24 +- .../Forms/PropertyGridToolStripButton.cs | 6 +- .../src/System/Windows/Forms/RadioButton.cs | 6 +- .../Windows/Forms/RadioButtonRenderer.cs | 12 +- .../Windows/Forms/RelatedCurrencyManager.cs | 2 +- .../src/System/Windows/Forms/RichTextBox.cs | 91 +++--- .../src/System/Windows/Forms/Screen.cs | 2 +- .../src/System/Windows/Forms/ScrollBar.cs | 6 +- .../System/Windows/Forms/ScrollableControl.cs | 4 +- .../src/System/Windows/Forms/SendKeys.cs | 4 +- ...EnumConverter.SpecialFolderEnumComparer.cs | 2 +- .../System/Windows/Forms/SplitContainer.cs | 8 +- .../src/System/Windows/Forms/Splitter.cs | 4 +- .../src/System/Windows/Forms/SplitterPanel.cs | 2 +- .../System/Windows/Forms/SystemInformation.cs | 6 +- .../Forms/TabControl.TabPageCollection.cs | 78 ++--- .../src/System/Windows/Forms/TabControl.cs | 18 +- .../src/System/Windows/Forms/TabPage.cs | 2 +- .../System/Windows/Forms/TableLayoutPanel.cs | 4 +- ...eLayoutSettings.TableLayoutSettingsStub.cs | 2 +- .../Windows/Forms/TableLayoutSettings.cs | 2 +- .../src/System/Windows/Forms/TaskDialog.cs | 2 +- .../System/Windows/Forms/TaskDialogButton.cs | 22 +- .../Forms/TaskDialogButtonCollection.cs | 4 +- .../Windows/Forms/TaskDialogFootnote.cs | 2 +- .../System/Windows/Forms/TaskDialogIcon.cs | 20 +- .../Forms/TaskDialogRadioButtonCollection.cs | 4 +- .../Forms/TaskDialogVerificationCheckBox.cs | 2 +- .../src/System/Windows/Forms/TextBox.cs | 4 +- .../src/System/Windows/Forms/TextBoxBase.cs | 12 +- .../src/System/Windows/Forms/TextRenderer.cs | 6 +- .../Windows/Forms/ThreadExceptionDialog.cs | 14 +- .../src/System/Windows/Forms/Timer.cs | 4 +- .../src/System/Windows/Forms/ToolStrip.cs | 54 ++-- .../System/Windows/Forms/ToolStripButton.cs | 6 +- .../System/Windows/Forms/ToolStripComboBox.cs | 18 +- .../Windows/Forms/ToolStripContentPanel.cs | 4 +- .../Windows/Forms/ToolStripControlHost.cs | 18 +- .../System/Windows/Forms/ToolStripDropDown.cs | 18 +- .../Windows/Forms/ToolStripDropDownItem.cs | 12 +- .../Windows/Forms/ToolStripDropDownMenu.cs | 10 +- .../Forms/ToolStripDropTargetManager.cs | 2 +- .../src/System/Windows/Forms/ToolStripGrip.cs | 2 +- .../Forms/ToolStripHighContrastRenderer.cs | 6 +- ...olStripItem.ToolStripItemInternalLayout.cs | 2 +- .../src/System/Windows/Forms/ToolStripItem.cs | 68 ++--- .../Forms/ToolStripManager.ModalMenuFilter.cs | 4 +- .../System/Windows/Forms/ToolStripManager.cs | 6 +- .../System/Windows/Forms/ToolStripMenuItem.cs | 12 +- .../System/Windows/Forms/ToolStripOverflow.cs | 2 +- .../System/Windows/Forms/ToolStripPanel.cs | 12 +- .../System/Windows/Forms/ToolStripPanelRow.cs | 4 +- .../Windows/Forms/ToolStripProgressBar.cs | 6 +- .../System/Windows/Forms/ToolStripRenderer.cs | 42 +-- .../Windows/Forms/ToolStripSeparator.cs | 2 +- .../Windows/Forms/ToolStripSplitButton.cs | 6 +- .../Forms/ToolStripSplitStackLayout.cs | 2 +- .../Windows/Forms/ToolStripStatusLabel.cs | 2 +- ...oolStripTextBox.ToolStripTextBoxControl.cs | 2 +- .../System/Windows/Forms/ToolStripTextBox.cs | 20 +- .../src/System/Windows/Forms/ToolTip.cs | 6 +- .../Forms/ToolstripProfessionalRenderer.cs | 4 +- .../src/System/Windows/Forms/TrackBar.cs | 8 +- .../src/System/Windows/Forms/TreeNode.cs | 32 +- .../src/System/Windows/Forms/TreeView.cs | 24 +- .../Windows/Forms/UpDownBase.UpDownButtons.cs | 4 +- .../src/System/Windows/Forms/UpDownBase.cs | 4 +- .../src/System/Windows/Forms/UserControl.cs | 2 +- .../Forms/VisualStyles/VisualStyleRenderer.cs | 34 +-- .../src/System/Windows/Forms/WebBrowser.cs | 4 +- .../System/Windows/Forms/WebBrowserBase.cs | 4 +- .../System/Windows/Forms/WebBrowserHelper.cs | 6 +- .../Windows/Forms/WebBrowserSiteBase.cs | 4 +- .../src/misc/InvariantComparer.cs | 2 +- .../AccessibilityTests/DataBindingExample.cs | 4 +- .../DesignSurface/DemoConsole/MainForm.cs | 2 +- .../DesignSurfaceExt/UndoEngineExt.cs | 4 +- .../TestDataSources.cs | 2 +- .../Infra/ScreenshotService.cs | 2 +- .../WinformsControlsTest/CollectionEditors.cs | 4 +- .../DataGridViewInVirtualModeTest.cs | 2 +- .../WinformsControlsTest/MessageBoxes.cs | 2 +- .../AxHost.ConnectionPointCookieTests.cs | 2 +- .../Windows/Forms/BindingSourceTests.cs | 2 +- .../Com2Interop/COM2FontConverterTests.cs | 2 +- .../Windows/Forms/ControlTests.Handlers.cs | 2 +- .../Windows/Forms/ControlTests.Methods.cs | 4 +- .../Windows/Forms/ControlTests.Properties.cs | 22 +- .../Windows/Forms/FeatureSupportTests.cs | 16 +- .../PropertyGridViewTests.Rendering.cs | 2 +- .../TestAccessors.PropertyGridTestAccessor.cs | 2 +- ...tAccessors.PropertyGridViewTestAccessor.cs | 2 +- .../Windows/Forms/ScrollableControlTests.cs | 10 +- .../System/Windows/Forms/StatusStripTests.cs | 2 +- ...KeyboardToolTipStateMachineTestAccessor.cs | 2 +- .../System/Windows/Forms/TextRendererTests.cs | 12 +- .../Windows/Forms/ToolStripItemTests.cs | 6 +- ...WindowsFormsSynchronizationContextTests.cs | 2 +- .../tests/UnitTests/TestAccessorTests.cs | 2 +- .../tests/UnitTests/Text/FontMetrics.cs | 4 +- 349 files changed, 1706 insertions(+), 1705 deletions(-) diff --git a/.editorconfig b/.editorconfig index bba08dd5e24..f81670e5047 100644 --- a/.editorconfig +++ b/.editorconfig @@ -32,7 +32,7 @@ dotnet_style_predefined_type_for_member_access = true:suggestion # name all constant fields using PascalCase dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields -dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style dotnet_naming_symbols.constant_fields.applicable_kinds = field dotnet_naming_symbols.constant_fields.required_modifiers = const @@ -42,7 +42,7 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case # static fields should have s_ prefix dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields -dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style +dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style dotnet_naming_symbols.static_fields.applicable_kinds = field dotnet_naming_symbols.static_fields.required_modifiers = static @@ -53,7 +53,7 @@ dotnet_naming_style.static_prefix_style.capitalization = camel_case # internal and private fields should be _camelCase dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields -dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style +dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style dotnet_naming_symbols.private_internal_fields.applicable_kinds = field dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal @@ -70,6 +70,21 @@ dotnet_style_collection_initializer = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion dotnet_style_coalesce_expression = true:suggestion dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +end_of_line = crlf +dotnet_style_allow_multiple_blank_lines_experimental = true:silent +dotnet_style_allow_statement_immediately_after_block_experimental = true:silent # C# files [*.cs] @@ -95,7 +110,7 @@ csharp_indent_switch_labels = true csharp_indent_labels = one_less_than_current # only use var when it's obvious what the variable type is -csharp_style_var_for_built_in_types = false:silent +csharp_style_var_for_built_in_types = false:error csharp_style_var_when_type_is_apparent = true:silent csharp_style_var_elsewhere = false:silent @@ -104,12 +119,12 @@ csharp_preserve_single_line_blocks = true csharp_preserve_single_line_statements = false # Expression-bodied members -csharp_style_expression_bodied_methods = false:none -csharp_style_expression_bodied_constructors = false:none -csharp_style_expression_bodied_operators = false:none -csharp_style_expression_bodied_properties = true:none -csharp_style_expression_bodied_indexers = true:none -csharp_style_expression_bodied_accessors = true:none +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_constructors = true:silent +csharp_style_expression_bodied_operators = true:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent # Pattern matching csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion @@ -146,6 +161,23 @@ csharp_space_between_square_brackets = false # IDE0008: Use explicit type dotnet_diagnostic.IDE0008.severity = silent +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_braces = true:silent +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent +# IDE0090: Use new() +dotnet_diagnostic.IDE0090.severity = error +csharp_style_deconstructed_variable_declaration = true:suggestion # Visual Basic files diff --git a/docs/testing.md b/docs/testing.md index 4cd82d1cbde..957d524b48e 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -126,7 +126,7 @@ Tests are built and executed by file name convention [WinFormsFact] public void ButtonBase_GetAutoSizeMode_Invoke_ReturnsExpected() { - using var control = new SubButtonBase(); + using SubButtonBase control = new(); Assert.Equal(AutoSizeMode.GrowOnly, control.GetAutoSizeMode()); } ``` @@ -163,8 +163,8 @@ When writing theories note the following: [WinFormsTheory] [MemberData(nameof(GetButton_TestData))] public void Ctor_Control_DataGridViewCellStyle(string buttonText) - { - using var button = new Button() { Text = buttonText }; + { + using Button button = new() { Text = buttonText }; ... } ``` @@ -184,7 +184,7 @@ When writing theories note the following: // ** DO NOT DO THIS! ** public static IEnumerable GetButton_TestData() { - var button = new Button(); + Button button = new(); yield return new object[] { button, new DataGridViewCellStyle() }; yield return new object[] { button { Text = "bla" }, new DataGridViewCellStyle() }; // the button could already be disposed by the time this theory runs } @@ -233,12 +233,12 @@ public void MyControl_Rendering() // 1. Create a control to validate rendering for. // 2. Add the control to a form, and make sure the form is created using Form form = new Form(); - using var control = new MyControl { ... }; + using MyControl control = new() { ... }; form.Controls.Add(control); Assert.NotEqual(IntPtr.Zero, form.Handle); // Create an Enhance Metafile into which we will render the control - using var emf = new EmfScope(); + using EmfScope emf = new(); DeviceContextState state = new DeviceContextState(emf); // Render the control diff --git a/src/Common/tests/TestUtilities/BinarySerialization.cs b/src/Common/tests/TestUtilities/BinarySerialization.cs index b247568b0b8..3fbd161d9b1 100644 --- a/src/Common/tests/TestUtilities/BinarySerialization.cs +++ b/src/Common/tests/TestUtilities/BinarySerialization.cs @@ -69,13 +69,13 @@ static object FromByteArray(byte[] raw, FormatterAssemblyStyle assemblyStyle = FormatterAssemblyStyle.Simple) { #pragma warning disable SYSLIB0011 // Type or member is obsolete - var binaryFormatter = new BinaryFormatter + BinaryFormatter binaryFormatter = new() { AssemblyFormat = assemblyStyle }; #pragma warning restore SYSLIB0011 // Type or member is obsolete - using var serializedStream = new MemoryStream(raw); + using MemoryStream serializedStream = new(raw); return binaryFormatter.Deserialize(serializedStream); } } @@ -90,15 +90,15 @@ static byte[] ToByteArray(object obj, FormatterAssemblyStyle assemblyStyle = FormatterAssemblyStyle.Simple) { #pragma warning disable SYSLIB0011 // Type or member is obsolete - var binaryFormatter = new BinaryFormatter + BinaryFormatter binaryFormatter = new() { AssemblyFormat = assemblyStyle }; #pragma warning restore SYSLIB0011 // Type or member is obsolete - using var ms = new MemoryStream(); - binaryFormatter.Serialize(ms, obj); - return ms.ToArray(); + using MemoryStream stream = new(); + binaryFormatter.Serialize(stream, obj); + return stream.ToArray(); } } #pragma warning restore SYSLIB0050 // Type or member is obsolete diff --git a/src/Common/tests/TestUtilities/DebuggerAttributes.cs b/src/Common/tests/TestUtilities/DebuggerAttributes.cs index e1c1c465835..fcfd25b495f 100644 --- a/src/Common/tests/TestUtilities/DebuggerAttributes.cs +++ b/src/Common/tests/TestUtilities/DebuggerAttributes.cs @@ -140,7 +140,7 @@ internal static string ValidateDebuggerDisplayReferences(object obj) throw new InvalidOperationException($"The DebuggerDisplayAttribute for {objType} doesn't reference any expressions."); } - var sb = new StringBuilder(); + StringBuilder sb = new(); for (int i = 0; i < segments.Length; i += 2) { diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs index a48cb8ae6b8..cba3a939eb9 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/InteractionTests.cs @@ -114,7 +114,7 @@ public void Shell_FileNotFoundException() private static Process StartTestProcess(string arguments) { - var startInfo = new ProcessStartInfo { FileName = _exePath, Arguments = arguments }; + ProcessStartInfo startInfo = new() { FileName = _exePath, Arguments = arguments }; return TestHelpers.StartProcess(startInfo); } diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs index 6212bb96618..2d1fc6eff94 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBaseTests.cs @@ -13,7 +13,7 @@ public class WindowsFormsApplicationBaseTests public void Run() { string exePath = TestHelpers.GetExePath("VisualBasicRuntimeTest"); - var startInfo = new ProcessStartInfo { FileName = exePath, Arguments = "WindowsFormsApplicationBase.Run" }; + ProcessStartInfo startInfo = new() { FileName = exePath, Arguments = "WindowsFormsApplicationBase.Run" }; Process process = TestHelpers.StartProcess(startInfo); TestHelpers.EndProcess(process, timeout: 1000); Assert.True(process.HasExited); @@ -34,7 +34,7 @@ public void RunSingleInstance() [Fact] public void Run_NoStartupFormException() { - var application = new WindowsFormsApplicationBase(); + WindowsFormsApplicationBase application = new(); // Exception.ToString() called to verify message is constructed successfully. _ = Assert.Throws(() => application.Run(Array.Empty())).ToString(); } diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/MyServices/Internal/ProgressDialogTests.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/MyServices/Internal/ProgressDialogTests.cs index 31d74d6abb4..a711db074de 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/MyServices/Internal/ProgressDialogTests.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft/VisualBasic/MyServices/Internal/ProgressDialogTests.cs @@ -12,8 +12,8 @@ public class ProgressDialogTests public void ShowProgressDialog() { string exePath = TestHelpers.GetExePath("VisualBasicRuntimeTest"); - var startInfo = new ProcessStartInfo { FileName = exePath, Arguments = "ProgressDialog.ShowProgressDialog" }; - var process = TestHelpers.StartProcess(startInfo); + ProcessStartInfo startInfo = new() { FileName = exePath, Arguments = "ProgressDialog.ShowProgressDialog" }; + Process process = TestHelpers.StartProcess(startInfo); TestHelpers.EndProcess(process, timeout: 1000); Assert.True(process.HasExited); Assert.NotEqual(2, process.ExitCode); diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/Program.cs b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/Program.cs index e5779843eef..e55ec64aea5 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/Program.cs +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/Program.cs @@ -79,8 +79,8 @@ private static void Interaction_MsgBox(bool useVbHost) private static void WindowsFormsApplicationBase_Run(bool isSingleInstance, bool isFirstInstance) { - var mainForm = new Form(); - var application = new WindowsApplication(mainForm, isSingleInstance); + Form mainForm = new(); + WindowsApplication application = new(mainForm, isSingleInstance); bool valid = false; bool loaded = false; @@ -131,7 +131,7 @@ private static void ProgressDialog_ShowProgressDialog() Type dialogType = typeof(ApplicationBase).Assembly.GetType("Microsoft.VisualBasic.MyServices.Internal.ProgressDialog"); var dialog = (Form)Activator.CreateInstance(dialogType, nonPublic: true); - var resources = new ResourceManager(dialogType); + ResourceManager resources = new(dialogType); var expectedValue = (Point)resources.GetObject("ProgressBarWork.Location"); if (expectedValue == new Point(0, 0)) { @@ -155,7 +155,7 @@ private static void VBInputBox_ShowDialog() Type formType = typeof(ApplicationBase).Assembly.GetType("Microsoft.VisualBasic.CompilerServices.VBInputBox"); var form = (Form)Activator.CreateInstance(formType, nonPublic: true); - var resources = new ResourceManager(formType); + ResourceManager resources = new(formType); var expectedValue = (Point)resources.GetObject("TextBox.Location"); if (expectedValue == new Point(0, 0)) { diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/SingleInstanceTests.cs b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/SingleInstanceTests.cs index 5ec2edc8973..90b665b5f92 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/SingleInstanceTests.cs +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/ApplicationServices/SingleInstanceTests.cs @@ -15,7 +15,7 @@ public class SingleInstanceTests private sealed class ReceivedArgs { - private List _received = new List(); + private List _received = new(); internal void Add(string[] args) { diff --git a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RECT.cs b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RECT.cs index fdd5de32a0e..450f6f21436 100644 --- a/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RECT.cs +++ b/src/System.Drawing.Common/src/Interop/Windows/Gdi32/Interop.RECT.cs @@ -16,7 +16,7 @@ public struct RECT public int right; public int bottom; - public Size Size => new Size(right - left, bottom - top); + public Size Size => new(right - left, bottom - top); } } } diff --git a/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs b/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs index 46e8457b3f6..2c505ab4b6b 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs @@ -248,13 +248,13 @@ public void MakeTransparent(Color transparentColor) // The new bitmap must be in 32bppARGB format, because that's the only // thing that supports alpha. (And that's what the image is initialized to -- transparent) - using var result = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb); + using Bitmap result = new(size.Width, size.Height, PixelFormat.Format32bppArgb); using var graphics = Graphics.FromImage(result); graphics.Clear(Color.Transparent); Rectangle rectangle = new Rectangle(0, 0, size.Width, size.Height); - using (var attributes = new ImageAttributes()) + using (ImageAttributes attributes = new()) { attributes.SetColorKey(transparentColor, transparentColor); graphics.DrawImage(this, rectangle, diff --git a/src/System.Drawing.Common/src/System/Drawing/Brushes.cs b/src/System.Drawing.Common/src/System/Drawing/Brushes.cs index 3444006d1bc..1bebcf5f67c 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Brushes.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Brushes.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Gdip = System.Drawing.SafeNativeMethods.Gdip; @@ -6,147 +6,147 @@ namespace System.Drawing; public static class Brushes { - private static readonly object s_transparentKey = new object(); - private static readonly object s_aliceBlueKey = new object(); - private static readonly object s_antiqueWhiteKey = new object(); - private static readonly object s_aquaKey = new object(); - private static readonly object s_aquamarineKey = new object(); - private static readonly object s_azureKey = new object(); - private static readonly object s_beigeKey = new object(); - private static readonly object s_bisqueKey = new object(); - private static readonly object s_blackKey = new object(); - private static readonly object s_blanchedAlmondKey = new object(); - private static readonly object s_blueKey = new object(); - private static readonly object s_blueVioletKey = new object(); - private static readonly object s_brownKey = new object(); - private static readonly object s_burlyWoodKey = new object(); - private static readonly object s_cadetBlueKey = new object(); - private static readonly object s_chartreuseKey = new object(); - private static readonly object s_chocolateKey = new object(); - private static readonly object s_coralKey = new object(); - private static readonly object s_cornflowerBlueKey = new object(); - private static readonly object s_cornsilkKey = new object(); - private static readonly object s_crimsonKey = new object(); - private static readonly object s_cyanKey = new object(); - private static readonly object s_darkBlueKey = new object(); - private static readonly object s_darkCyanKey = new object(); - private static readonly object s_darkGoldenrodKey = new object(); - private static readonly object s_darkGrayKey = new object(); - private static readonly object s_darkGreenKey = new object(); - private static readonly object s_darkKhakiKey = new object(); - private static readonly object s_darkMagentaKey = new object(); - private static readonly object s_darkOliveGreenKey = new object(); - private static readonly object s_darkOrangeKey = new object(); - private static readonly object s_darkOrchidKey = new object(); - private static readonly object s_darkRedKey = new object(); - private static readonly object s_darkSalmonKey = new object(); - private static readonly object s_darkSeaGreenKey = new object(); - private static readonly object s_darkSlateBlueKey = new object(); - private static readonly object s_darkSlateGrayKey = new object(); - private static readonly object s_darkTurquoiseKey = new object(); - private static readonly object s_darkVioletKey = new object(); - private static readonly object s_deepPinkKey = new object(); - private static readonly object s_deepSkyBlueKey = new object(); - private static readonly object s_dimGrayKey = new object(); - private static readonly object s_dodgerBlueKey = new object(); - private static readonly object s_firebrickKey = new object(); - private static readonly object s_floralWhiteKey = new object(); - private static readonly object s_forestGreenKey = new object(); - private static readonly object s_fuchsiaKey = new object(); - private static readonly object s_gainsboroKey = new object(); - private static readonly object s_ghostWhiteKey = new object(); - private static readonly object s_goldKey = new object(); - private static readonly object s_goldenrodKey = new object(); - private static readonly object s_grayKey = new object(); - private static readonly object s_greenKey = new object(); - private static readonly object s_greenYellowKey = new object(); - private static readonly object s_honeydewKey = new object(); - private static readonly object s_hotPinkKey = new object(); - private static readonly object s_indianRedKey = new object(); - private static readonly object s_indigoKey = new object(); - private static readonly object s_ivoryKey = new object(); - private static readonly object s_khakiKey = new object(); - private static readonly object s_lavenderKey = new object(); - private static readonly object s_lavenderBlushKey = new object(); - private static readonly object s_lawnGreenKey = new object(); - private static readonly object s_lemonChiffonKey = new object(); - private static readonly object s_lightBlueKey = new object(); - private static readonly object s_lightCoralKey = new object(); - private static readonly object s_lightCyanKey = new object(); - private static readonly object s_lightGoldenrodYellowKey = new object(); - private static readonly object s_lightGreenKey = new object(); - private static readonly object s_lightGrayKey = new object(); - private static readonly object s_lightPinkKey = new object(); - private static readonly object s_lightSalmonKey = new object(); - private static readonly object s_lightSeaGreenKey = new object(); - private static readonly object s_lightSkyBlueKey = new object(); - private static readonly object s_lightSlateGrayKey = new object(); - private static readonly object s_lightSteelBlueKey = new object(); - private static readonly object s_lightYellowKey = new object(); - private static readonly object s_limeKey = new object(); - private static readonly object s_limeGreenKey = new object(); - private static readonly object s_linenKey = new object(); - private static readonly object s_magentaKey = new object(); - private static readonly object s_maroonKey = new object(); - private static readonly object s_mediumAquamarineKey = new object(); - private static readonly object s_mediumBlueKey = new object(); - private static readonly object s_mediumOrchidKey = new object(); - private static readonly object s_mediumPurpleKey = new object(); - private static readonly object s_mediumSeaGreenKey = new object(); - private static readonly object s_mediumSlateBlueKey = new object(); - private static readonly object s_mediumSpringGreenKey = new object(); - private static readonly object s_mediumTurquoiseKey = new object(); - private static readonly object s_mediumVioletRedKey = new object(); - private static readonly object s_midnightBlueKey = new object(); - private static readonly object s_mintCreamKey = new object(); - private static readonly object s_mistyRoseKey = new object(); - private static readonly object s_moccasinKey = new object(); - private static readonly object s_navajoWhiteKey = new object(); - private static readonly object s_navyKey = new object(); - private static readonly object s_oldLaceKey = new object(); - private static readonly object s_oliveKey = new object(); - private static readonly object s_oliveDrabKey = new object(); - private static readonly object s_orangeKey = new object(); - private static readonly object s_orangeRedKey = new object(); - private static readonly object s_orchidKey = new object(); - private static readonly object s_paleGoldenrodKey = new object(); - private static readonly object s_paleGreenKey = new object(); - private static readonly object s_paleTurquoiseKey = new object(); - private static readonly object s_paleVioletRedKey = new object(); - private static readonly object s_papayaWhipKey = new object(); - private static readonly object s_peachPuffKey = new object(); - private static readonly object s_peruKey = new object(); - private static readonly object s_pinkKey = new object(); - private static readonly object s_plumKey = new object(); - private static readonly object s_powderBlueKey = new object(); - private static readonly object s_purpleKey = new object(); - private static readonly object s_redKey = new object(); - private static readonly object s_rosyBrownKey = new object(); - private static readonly object s_royalBlueKey = new object(); - private static readonly object s_saddleBrownKey = new object(); - private static readonly object s_salmonKey = new object(); - private static readonly object s_sandyBrownKey = new object(); - private static readonly object s_seaGreenKey = new object(); - private static readonly object s_seaShellKey = new object(); - private static readonly object s_siennaKey = new object(); - private static readonly object s_silverKey = new object(); - private static readonly object s_skyBlueKey = new object(); - private static readonly object s_slateBlueKey = new object(); - private static readonly object s_slateGrayKey = new object(); - private static readonly object s_snowKey = new object(); - private static readonly object s_springGreenKey = new object(); - private static readonly object s_steelBlueKey = new object(); - private static readonly object s_tanKey = new object(); - private static readonly object s_tealKey = new object(); - private static readonly object s_thistleKey = new object(); - private static readonly object s_tomatoKey = new object(); - private static readonly object s_turquoiseKey = new object(); - private static readonly object s_violetKey = new object(); - private static readonly object s_wheatKey = new object(); - private static readonly object s_whiteKey = new object(); - private static readonly object s_whiteSmokeKey = new object(); - private static readonly object s_yellowKey = new object(); - private static readonly object s_yellowGreenKey = new object(); + private static readonly object s_transparentKey = new(); + private static readonly object s_aliceBlueKey = new(); + private static readonly object s_antiqueWhiteKey = new(); + private static readonly object s_aquaKey = new(); + private static readonly object s_aquamarineKey = new(); + private static readonly object s_azureKey = new(); + private static readonly object s_beigeKey = new(); + private static readonly object s_bisqueKey = new(); + private static readonly object s_blackKey = new(); + private static readonly object s_blanchedAlmondKey = new(); + private static readonly object s_blueKey = new(); + private static readonly object s_blueVioletKey = new(); + private static readonly object s_brownKey = new(); + private static readonly object s_burlyWoodKey = new(); + private static readonly object s_cadetBlueKey = new(); + private static readonly object s_chartreuseKey = new(); + private static readonly object s_chocolateKey = new(); + private static readonly object s_coralKey = new(); + private static readonly object s_cornflowerBlueKey = new(); + private static readonly object s_cornsilkKey = new(); + private static readonly object s_crimsonKey = new(); + private static readonly object s_cyanKey = new(); + private static readonly object s_darkBlueKey = new(); + private static readonly object s_darkCyanKey = new(); + private static readonly object s_darkGoldenrodKey = new(); + private static readonly object s_darkGrayKey = new(); + private static readonly object s_darkGreenKey = new(); + private static readonly object s_darkKhakiKey = new(); + private static readonly object s_darkMagentaKey = new(); + private static readonly object s_darkOliveGreenKey = new(); + private static readonly object s_darkOrangeKey = new(); + private static readonly object s_darkOrchidKey = new(); + private static readonly object s_darkRedKey = new(); + private static readonly object s_darkSalmonKey = new(); + private static readonly object s_darkSeaGreenKey = new(); + private static readonly object s_darkSlateBlueKey = new(); + private static readonly object s_darkSlateGrayKey = new(); + private static readonly object s_darkTurquoiseKey = new(); + private static readonly object s_darkVioletKey = new(); + private static readonly object s_deepPinkKey = new(); + private static readonly object s_deepSkyBlueKey = new(); + private static readonly object s_dimGrayKey = new(); + private static readonly object s_dodgerBlueKey = new(); + private static readonly object s_firebrickKey = new(); + private static readonly object s_floralWhiteKey = new(); + private static readonly object s_forestGreenKey = new(); + private static readonly object s_fuchsiaKey = new(); + private static readonly object s_gainsboroKey = new(); + private static readonly object s_ghostWhiteKey = new(); + private static readonly object s_goldKey = new(); + private static readonly object s_goldenrodKey = new(); + private static readonly object s_grayKey = new(); + private static readonly object s_greenKey = new(); + private static readonly object s_greenYellowKey = new(); + private static readonly object s_honeydewKey = new(); + private static readonly object s_hotPinkKey = new(); + private static readonly object s_indianRedKey = new(); + private static readonly object s_indigoKey = new(); + private static readonly object s_ivoryKey = new(); + private static readonly object s_khakiKey = new(); + private static readonly object s_lavenderKey = new(); + private static readonly object s_lavenderBlushKey = new(); + private static readonly object s_lawnGreenKey = new(); + private static readonly object s_lemonChiffonKey = new(); + private static readonly object s_lightBlueKey = new(); + private static readonly object s_lightCoralKey = new(); + private static readonly object s_lightCyanKey = new(); + private static readonly object s_lightGoldenrodYellowKey = new(); + private static readonly object s_lightGreenKey = new(); + private static readonly object s_lightGrayKey = new(); + private static readonly object s_lightPinkKey = new(); + private static readonly object s_lightSalmonKey = new(); + private static readonly object s_lightSeaGreenKey = new(); + private static readonly object s_lightSkyBlueKey = new(); + private static readonly object s_lightSlateGrayKey = new(); + private static readonly object s_lightSteelBlueKey = new(); + private static readonly object s_lightYellowKey = new(); + private static readonly object s_limeKey = new(); + private static readonly object s_limeGreenKey = new(); + private static readonly object s_linenKey = new(); + private static readonly object s_magentaKey = new(); + private static readonly object s_maroonKey = new(); + private static readonly object s_mediumAquamarineKey = new(); + private static readonly object s_mediumBlueKey = new(); + private static readonly object s_mediumOrchidKey = new(); + private static readonly object s_mediumPurpleKey = new(); + private static readonly object s_mediumSeaGreenKey = new(); + private static readonly object s_mediumSlateBlueKey = new(); + private static readonly object s_mediumSpringGreenKey = new(); + private static readonly object s_mediumTurquoiseKey = new(); + private static readonly object s_mediumVioletRedKey = new(); + private static readonly object s_midnightBlueKey = new(); + private static readonly object s_mintCreamKey = new(); + private static readonly object s_mistyRoseKey = new(); + private static readonly object s_moccasinKey = new(); + private static readonly object s_navajoWhiteKey = new(); + private static readonly object s_navyKey = new(); + private static readonly object s_oldLaceKey = new(); + private static readonly object s_oliveKey = new(); + private static readonly object s_oliveDrabKey = new(); + private static readonly object s_orangeKey = new(); + private static readonly object s_orangeRedKey = new(); + private static readonly object s_orchidKey = new(); + private static readonly object s_paleGoldenrodKey = new(); + private static readonly object s_paleGreenKey = new(); + private static readonly object s_paleTurquoiseKey = new(); + private static readonly object s_paleVioletRedKey = new(); + private static readonly object s_papayaWhipKey = new(); + private static readonly object s_peachPuffKey = new(); + private static readonly object s_peruKey = new(); + private static readonly object s_pinkKey = new(); + private static readonly object s_plumKey = new(); + private static readonly object s_powderBlueKey = new(); + private static readonly object s_purpleKey = new(); + private static readonly object s_redKey = new(); + private static readonly object s_rosyBrownKey = new(); + private static readonly object s_royalBlueKey = new(); + private static readonly object s_saddleBrownKey = new(); + private static readonly object s_salmonKey = new(); + private static readonly object s_sandyBrownKey = new(); + private static readonly object s_seaGreenKey = new(); + private static readonly object s_seaShellKey = new(); + private static readonly object s_siennaKey = new(); + private static readonly object s_silverKey = new(); + private static readonly object s_skyBlueKey = new(); + private static readonly object s_slateBlueKey = new(); + private static readonly object s_slateGrayKey = new(); + private static readonly object s_snowKey = new(); + private static readonly object s_springGreenKey = new(); + private static readonly object s_steelBlueKey = new(); + private static readonly object s_tanKey = new(); + private static readonly object s_tealKey = new(); + private static readonly object s_thistleKey = new(); + private static readonly object s_tomatoKey = new(); + private static readonly object s_turquoiseKey = new(); + private static readonly object s_violetKey = new(); + private static readonly object s_wheatKey = new(); + private static readonly object s_whiteKey = new(); + private static readonly object s_whiteSmokeKey = new(); + private static readonly object s_yellowKey = new(); + private static readonly object s_yellowGreenKey = new(); public static Brush Transparent => GetBrush(s_transparentKey, Color.Transparent); diff --git a/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs b/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs index 675ef3a3748..c6be45bf672 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -202,7 +202,7 @@ public Blend? Blend Gdip.CheckStatus(Gdip.GdipGetLineBlend(new HandleRef(this, NativeBrush), factors, positions, count)); // Return the result in a managed array. - var blend = new Blend(count); + Blend blend = new(count); Marshal.Copy(factors, blend.Factors, 0, count); Marshal.Copy(positions, blend.Positions, 0, count); @@ -335,7 +335,7 @@ public ColorBlend InterpolationColors Gdip.CheckStatus(Gdip.GdipGetLinePresetBlend(new HandleRef(this, NativeBrush), colors, positions, count)); // Return the result in a managed array. - var blend = new ColorBlend(count); + ColorBlend blend = new(count); int[] argb = new int[count]; Marshal.Copy(colors, argb, 0, count); @@ -455,7 +455,7 @@ public Matrix Transform { get { - var matrix = new Matrix(); + Matrix matrix = new(); Gdip.CheckStatus(Gdip.GdipGetLineTransform(new HandleRef(this, NativeBrush), new HandleRef(matrix, matrix.NativeMatrix))); return matrix; } diff --git a/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs b/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs index 4ef5b791579..7b0bd34d7de 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs @@ -55,5 +55,5 @@ protected override bool ReleaseHandle() public static implicit operator IntPtr(SafeCustomLineCapHandle handle) => handle?.handle ?? IntPtr.Zero; - public static explicit operator SafeCustomLineCapHandle(IntPtr handle) => new SafeCustomLineCapHandle(handle); + public static explicit operator SafeCustomLineCapHandle(IntPtr handle) => new(handle); } diff --git a/src/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs b/src/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs index e1d1ab94a74..548871b1287 100644 --- a/src/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs +++ b/src/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs @@ -17,7 +17,7 @@ namespace System.Drawing; internal unsafe partial class DrawingCom : ComWrappers { private const int S_OK = (int)HRESULT.S_OK; - private static readonly Guid IID_IStream = new Guid(0x0000000C, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); + private static readonly Guid IID_IStream = new(0x0000000C, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); private static readonly ComInterfaceEntry* s_wrapperEntry = InitializeComInterfaceEntry(); @@ -283,7 +283,7 @@ private static int Clone(IntPtr thisPtr, IntPtr* ppstm) internal interface IPicture : IDisposable { - static readonly Guid IID = new Guid(0x7BF80980, 0xBF32, 0x101A, 0x8B, 0xBB, 0, 0xAA, 0x00, 0x30, 0x0C, 0xAB); + static readonly Guid IID = new(0x7BF80980, 0xBF32, 0x101A, 0x8B, 0xBB, 0, 0xAA, 0x00, 0x30, 0x0C, 0xAB); // NOTE: Only SaveAsFile is invoked. The other methods on IPicture are not necessary diff --git a/src/System.Drawing.Common/src/System/Drawing/FontFamily.cs b/src/System.Drawing.Common/src/System/Drawing/FontFamily.cs index ca7fbf8bfcd..fe73b9fb095 100644 --- a/src/System.Drawing.Common/src/System/Drawing/FontFamily.cs +++ b/src/System.Drawing.Common/src/System/Drawing/FontFamily.cs @@ -18,7 +18,7 @@ public sealed class FontFamily : MarshalByRefObject, IDisposable private readonly bool _createDefaultOnFail; #if DEBUG - private static readonly object s_lockObj = new object(); + private static readonly object s_lockObj = new(); private static int s_idCount; private int _id; #endif @@ -216,7 +216,7 @@ public unsafe string GetName(int language) /// /// Gets a generic SansSerif . /// - public static FontFamily GenericSansSerif => new FontFamily(GetGdipGenericSansSerif()); + public static FontFamily GenericSansSerif => new(GetGdipGenericSansSerif()); private static IntPtr GetGdipGenericSansSerif() { @@ -230,12 +230,12 @@ private static IntPtr GetGdipGenericSansSerif() /// /// Gets a generic Serif . /// - public static FontFamily GenericSerif => new FontFamily(GenericFontFamilies.Serif); + public static FontFamily GenericSerif => new(GenericFontFamilies.Serif); /// /// Gets a generic monospace . /// - public static FontFamily GenericMonospace => new FontFamily(GenericFontFamilies.Monospace); + public static FontFamily GenericMonospace => new(GenericFontFamilies.Monospace); /// /// Returns an array that contains all of the objects associated with the specified diff --git a/src/System.Drawing.Common/src/System/Drawing/Graphics.cs b/src/System.Drawing.Common/src/System/Drawing/Graphics.cs index e8928050c74..39f97465381 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Graphics.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Graphics.cs @@ -44,7 +44,7 @@ internal static string GetAllocationStack() { /// private GraphicsContext? _previousContext; - private static readonly object s_syncObject = new object(); + private static readonly object s_syncObject = new(); // Object reference used for printing; it could point to a PrintPreviewGraphics to obtain the VisibleClipBounds, or // a DeviceContext holding a printer DC. diff --git a/src/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs b/src/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs index 56335e5dbf6..32ce2dacd6e 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs @@ -88,6 +88,6 @@ private unsafe PICTDESC(int picType, IntPtr hicon) } public static PICTDESC CreateIconPICTDESC(IntPtr hicon) => - new PICTDESC(Ole.PICTYPE_ICON, hicon); + new(Ole.PICTYPE_ICON, hicon); } } diff --git a/src/System.Drawing.Common/src/System/Drawing/Image.cs b/src/System.Drawing.Common/src/System/Drawing/Image.cs index bb19e432168..53f11648d41 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Image.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Image.cs @@ -513,7 +513,7 @@ public SizeF PhysicalDimension /// /// Gets the width and height of this . /// - public Size Size => new Size(Width, Height); + public Size Size => new(Width, Height); /// /// Gets the width of this . diff --git a/src/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs b/src/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs index 2492d9255ca..40c84cea075 100644 --- a/src/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs +++ b/src/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs @@ -61,7 +61,7 @@ public sealed partial class ImageAnimator /// access to it for a single thread. Observe that synchronization access to image objects are done /// with critical sections (lock). /// - private static readonly ReaderWriterLock s_rwImgListLock = new ReaderWriterLock(); + private static readonly ReaderWriterLock s_rwImgListLock = new(); /// /// Flag to avoid a deadlock when waiting on a write-lock and an attempt to acquire a read-lock is diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs index b3b7a5c4d12..fbd36c32512 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs @@ -5,31 +5,31 @@ namespace System.Drawing.Imaging; public sealed class Encoder { - public static readonly Encoder Compression = new Encoder(new Guid(unchecked((int)0xe09d739d), unchecked((short)0xccd4), unchecked((short)0x44ee), new byte[] { 0x8e, 0xba, 0x3f, 0xbf, 0x8b, 0xe4, 0xfc, 0x58 })); - public static readonly Encoder ColorDepth = new Encoder(new Guid(0x66087055, unchecked((short)0xad66), unchecked((short)0x4c7c), new byte[] { 0x9a, 0x18, 0x38, 0xa2, 0x31, 0x0b, 0x83, 0x37 })); - public static readonly Encoder ScanMethod = new Encoder(new Guid(0x3a4e2661, (short)0x3109, (short)0x4e56, new byte[] { 0x85, 0x36, 0x42, 0xc1, 0x56, 0xe7, 0xdc, 0xfa })); - public static readonly Encoder Version = new Encoder(new Guid(0x24d18c76, unchecked((short)0x814a), unchecked((short)0x41a4), new byte[] { 0xbf, 0x53, 0x1c, 0x21, 0x9c, 0xcc, 0xf7, 0x97 })); - public static readonly Encoder RenderMethod = new Encoder(new Guid(0x6d42c53a, (short)0x229a, (short)0x4825, new byte[] { 0x8b, 0xb7, 0x5c, 0x99, 0xe2, 0xb9, 0xa8, 0xb8 })); - public static readonly Encoder Quality = new Encoder(new Guid(0x1d5be4b5, unchecked((short)0xfa4a), unchecked((short)0x452d), new byte[] { 0x9c, 0xdd, 0x5d, 0xb3, 0x51, 0x05, 0xe7, 0xeb })); - public static readonly Encoder Transformation = new Encoder(new Guid(unchecked((int)0x8d0eb2d1), unchecked((short)0xa58e), unchecked((short)0x4ea8), new byte[] { 0xaa, 0x14, 0x10, 0x80, 0x74, 0xb7, 0xb6, 0xf9 })); - public static readonly Encoder LuminanceTable = new Encoder(new Guid(unchecked((int)0xedb33bce), unchecked((short)0x0266), unchecked((short)0x4a77), new byte[] { 0xb9, 0x04, 0x27, 0x21, 0x60, 0x99, 0xe7, 0x17 })); - public static readonly Encoder ChrominanceTable = new Encoder(new Guid(unchecked((int)0xf2e455dc), unchecked((short)0x09b3), unchecked((short)0x4316), new byte[] { 0x82, 0x60, 0x67, 0x6a, 0xda, 0x32, 0x48, 0x1c })); - public static readonly Encoder SaveFlag = new Encoder(new Guid(unchecked((int)0x292266fc), unchecked((short)0xac40), unchecked((short)0x47bf), new byte[] { 0x8c, 0xfc, 0xa8, 0x5b, 0x89, 0xa6, 0x55, 0xde })); + public static readonly Encoder Compression = new(new Guid(unchecked((int)0xe09d739d), unchecked((short)0xccd4), unchecked((short)0x44ee), new byte[] { 0x8e, 0xba, 0x3f, 0xbf, 0x8b, 0xe4, 0xfc, 0x58 })); + public static readonly Encoder ColorDepth = new(new Guid(0x66087055, unchecked((short)0xad66), unchecked((short)0x4c7c), new byte[] { 0x9a, 0x18, 0x38, 0xa2, 0x31, 0x0b, 0x83, 0x37 })); + public static readonly Encoder ScanMethod = new(new Guid(0x3a4e2661, (short)0x3109, (short)0x4e56, new byte[] { 0x85, 0x36, 0x42, 0xc1, 0x56, 0xe7, 0xdc, 0xfa })); + public static readonly Encoder Version = new(new Guid(0x24d18c76, unchecked((short)0x814a), unchecked((short)0x41a4), new byte[] { 0xbf, 0x53, 0x1c, 0x21, 0x9c, 0xcc, 0xf7, 0x97 })); + public static readonly Encoder RenderMethod = new(new Guid(0x6d42c53a, (short)0x229a, (short)0x4825, new byte[] { 0x8b, 0xb7, 0x5c, 0x99, 0xe2, 0xb9, 0xa8, 0xb8 })); + public static readonly Encoder Quality = new(new Guid(0x1d5be4b5, unchecked((short)0xfa4a), unchecked((short)0x452d), new byte[] { 0x9c, 0xdd, 0x5d, 0xb3, 0x51, 0x05, 0xe7, 0xeb })); + public static readonly Encoder Transformation = new(new Guid(unchecked((int)0x8d0eb2d1), unchecked((short)0xa58e), unchecked((short)0x4ea8), new byte[] { 0xaa, 0x14, 0x10, 0x80, 0x74, 0xb7, 0xb6, 0xf9 })); + public static readonly Encoder LuminanceTable = new(new Guid(unchecked((int)0xedb33bce), unchecked((short)0x0266), unchecked((short)0x4a77), new byte[] { 0xb9, 0x04, 0x27, 0x21, 0x60, 0x99, 0xe7, 0x17 })); + public static readonly Encoder ChrominanceTable = new(new Guid(unchecked((int)0xf2e455dc), unchecked((short)0x09b3), unchecked((short)0x4316), new byte[] { 0x82, 0x60, 0x67, 0x6a, 0xda, 0x32, 0x48, 0x1c })); + public static readonly Encoder SaveFlag = new(new Guid(unchecked((int)0x292266fc), unchecked((short)0xac40), unchecked((short)0x47bf), new byte[] { 0x8c, 0xfc, 0xa8, 0x5b, 0x89, 0xa6, 0x55, 0xde })); /// /// An object that is initialized with the globally unique identifier for the color space category. /// - public static readonly Encoder ColorSpace = new Encoder(new Guid(unchecked((int)0xae7a62a0), unchecked((short)0xee2c), unchecked((short)0x49d8), new byte[] { 0x9d, 0x07, 0x1b, 0xa8, 0xa9, 0x27, 0x59, 0x6e })); + public static readonly Encoder ColorSpace = new(new Guid(unchecked((int)0xae7a62a0), unchecked((short)0xee2c), unchecked((short)0x49d8), new byte[] { 0x9d, 0x07, 0x1b, 0xa8, 0xa9, 0x27, 0x59, 0x6e })); /// /// An object that is initialized with the globally unique identifier for the image items category. /// - public static readonly Encoder ImageItems = new Encoder(new Guid(unchecked((int)0x63875e13), unchecked((short)0x1f1d), unchecked((short)0x45ab), new byte[] { 0x91, 0x95, 0xa2, 0x9b, 0x60, 0x66, 0xa6, 0x50 })); + public static readonly Encoder ImageItems = new(new Guid(unchecked((int)0x63875e13), unchecked((short)0x1f1d), unchecked((short)0x45ab), new byte[] { 0x91, 0x95, 0xa2, 0x9b, 0x60, 0x66, 0xa6, 0x50 })); /// /// An object that is initialized with the globally unique identifier for the save as CMYK category. /// - public static readonly Encoder SaveAsCmyk = new Encoder(new Guid(unchecked((int)0xa219bbc9), unchecked((short)0x0a9d), unchecked((short)0x4005), new byte[] { 0xa3, 0xee, 0x3a, 0x42, 0x1b, 0x8b, 0xb0, 0x6c })); + public static readonly Encoder SaveAsCmyk = new(new Guid(unchecked((int)0xa219bbc9), unchecked((short)0x0a9d), unchecked((short)0x4005), new byte[] { 0xa3, 0xee, 0x3a, 0x42, 0x1b, 0x8b, 0xb0, 0x6c })); private Guid _guid; diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs index bdcd5ae32db..d94f4a75b67 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs @@ -27,7 +27,7 @@ public sealed unsafe class EncoderParameter : IDisposable /// public Encoder Encoder { - get => new Encoder(_parameterGuid); + get => new(_parameterGuid); set => _parameterGuid = value.Guid; } diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs index 84c25edab89..0e8455d5511 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs @@ -6,9 +6,9 @@ namespace System.Drawing.Imaging; public sealed class FrameDimension { // Frame dimension GUIDs, from sdkinc\imgguids.h - private static readonly FrameDimension s_time = new FrameDimension(new Guid("{6aedbd6d-3fb5-418a-83a6-7f45229dc872}")); - private static readonly FrameDimension s_resolution = new FrameDimension(new Guid("{84236f7b-3bd3-428f-8dab-4ea1439ca315}")); - private static readonly FrameDimension s_page = new FrameDimension(new Guid("{7462dc86-6180-4c7e-8e3f-ee7333a7a483}")); + private static readonly FrameDimension s_time = new(new Guid("{6aedbd6d-3fb5-418a-83a6-7f45229dc872}")); + private static readonly FrameDimension s_resolution = new(new Guid("{84236f7b-3bd3-428f-8dab-4ea1439ca315}")); + private static readonly FrameDimension s_page = new(new Guid("{7462dc86-6180-4c7e-8e3f-ee7333a7a483}")); private Guid _guid; diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs index 2049edebb11..5d984503d32 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs @@ -499,7 +499,7 @@ public void ClearBrushRemapTable() public void SetWrapMode(WrapMode mode) { - SetWrapMode(mode, default(Color), false); + SetWrapMode(mode, default, false); } public void SetWrapMode(WrapMode mode, Color color) diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs index e936747c64d..8d636865a5f 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs @@ -14,18 +14,18 @@ public sealed class ImageFormat { // Format IDs // private static ImageFormat undefined = new ImageFormat(new Guid("{b96b3ca9-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_memoryBMP = new ImageFormat(new Guid("{b96b3caa-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_bmp = new ImageFormat(new Guid("{b96b3cab-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_emf = new ImageFormat(new Guid("{b96b3cac-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_wmf = new ImageFormat(new Guid("{b96b3cad-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_jpeg = new ImageFormat(new Guid("{b96b3cae-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_png = new ImageFormat(new Guid("{b96b3caf-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_gif = new ImageFormat(new Guid("{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_tiff = new ImageFormat(new Guid("{b96b3cb1-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_exif = new ImageFormat(new Guid("{b96b3cb2-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_icon = new ImageFormat(new Guid("{b96b3cb5-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_heif = new ImageFormat(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}")); - private static readonly ImageFormat s_webp = new ImageFormat(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_memoryBMP = new(new Guid("{b96b3caa-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_bmp = new(new Guid("{b96b3cab-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_emf = new(new Guid("{b96b3cac-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_wmf = new(new Guid("{b96b3cad-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_jpeg = new(new Guid("{b96b3cae-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_png = new(new Guid("{b96b3caf-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_gif = new(new Guid("{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_tiff = new(new Guid("{b96b3cb1-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_exif = new(new Guid("{b96b3cb2-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_icon = new(new Guid("{b96b3cb5-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_heif = new(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}")); + private static readonly ImageFormat s_webp = new(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}")); private Guid _guid; diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs index cebaa528b8c..9cd530b68a9 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs @@ -34,7 +34,7 @@ internal sealed class MetafileHeaderWmf #pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's. [MarshalAs(UnmanagedType.Struct)] #pragma warning restore CS0618 - public MetaHeader WmfHeader = new MetaHeader(); + public MetaHeader WmfHeader = new(); public int dummy1; public int dummy2; public int dummy3; diff --git a/src/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs b/src/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs index 995808e3bca..1223bd7d8d0 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs @@ -19,7 +19,7 @@ internal static class SystemColorTracker private static WeakReference[] list = new WeakReference[INITIAL_SIZE]; private static int count; private static bool addedTracker; - private static readonly object lockObject = new object(); + private static readonly object lockObject = new(); internal static void Add(ISystemColorTracker obj) { diff --git a/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs b/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs index 2dc0e960929..d96eab2c4c1 100644 --- a/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs +++ b/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs @@ -7,7 +7,7 @@ namespace System.Drawing; internal static class NativeMethods { - internal static HandleRef NullHandleRef => new HandleRef(null, IntPtr.Zero); + internal static HandleRef NullHandleRef => new(null, IntPtr.Zero); public const int MAX_PATH = 260; internal const int SM_REMOTESESSION = 0x1000; diff --git a/src/System.Drawing.Common/src/System/Drawing/Pens.cs b/src/System.Drawing.Common/src/System/Drawing/Pens.cs index 30c8c7dbebf..96b498afdaf 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Pens.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Pens.cs @@ -6,147 +6,147 @@ namespace System.Drawing; public static class Pens { - private static readonly object s_transparentKey = new object(); - private static readonly object s_aliceBlueKey = new object(); - private static readonly object s_antiqueWhiteKey = new object(); - private static readonly object s_aquaKey = new object(); - private static readonly object s_aquamarineKey = new object(); - private static readonly object s_azureKey = new object(); - private static readonly object s_beigeKey = new object(); - private static readonly object s_bisqueKey = new object(); - private static readonly object s_blackKey = new object(); - private static readonly object s_blanchedAlmondKey = new object(); - private static readonly object s_blueKey = new object(); - private static readonly object s_blueVioletKey = new object(); - private static readonly object s_brownKey = new object(); - private static readonly object s_burlyWoodKey = new object(); - private static readonly object s_cadetBlueKey = new object(); - private static readonly object s_chartreuseKey = new object(); - private static readonly object s_chocolateKey = new object(); - private static readonly object s_coralKey = new object(); - private static readonly object s_cornflowerBlueKey = new object(); - private static readonly object s_cornsilkKey = new object(); - private static readonly object s_crimsonKey = new object(); - private static readonly object s_cyanKey = new object(); - private static readonly object s_darkBlueKey = new object(); - private static readonly object s_darkCyanKey = new object(); - private static readonly object s_darkGoldenrodKey = new object(); - private static readonly object s_darkGrayKey = new object(); - private static readonly object s_darkGreenKey = new object(); - private static readonly object s_darkKhakiKey = new object(); - private static readonly object s_darkMagentaKey = new object(); - private static readonly object s_darkOliveGreenKey = new object(); - private static readonly object s_darkOrangeKey = new object(); - private static readonly object s_darkOrchidKey = new object(); - private static readonly object s_darkRedKey = new object(); - private static readonly object s_darkSalmonKey = new object(); - private static readonly object s_darkSeaGreenKey = new object(); - private static readonly object s_darkSlateBlueKey = new object(); - private static readonly object s_darkSlateGrayKey = new object(); - private static readonly object s_darkTurquoiseKey = new object(); - private static readonly object s_darkVioletKey = new object(); - private static readonly object s_deepPinkKey = new object(); - private static readonly object s_deepSkyBlueKey = new object(); - private static readonly object s_dimGrayKey = new object(); - private static readonly object s_dodgerBlueKey = new object(); - private static readonly object s_firebrickKey = new object(); - private static readonly object s_floralWhiteKey = new object(); - private static readonly object s_forestGreenKey = new object(); - private static readonly object s_fuchsiaKey = new object(); - private static readonly object s_gainsboroKey = new object(); - private static readonly object s_ghostWhiteKey = new object(); - private static readonly object s_goldKey = new object(); - private static readonly object s_goldenrodKey = new object(); - private static readonly object s_grayKey = new object(); - private static readonly object s_greenKey = new object(); - private static readonly object s_greenYellowKey = new object(); - private static readonly object s_honeydewKey = new object(); - private static readonly object s_hotPinkKey = new object(); - private static readonly object s_indianRedKey = new object(); - private static readonly object s_indigoKey = new object(); - private static readonly object s_ivoryKey = new object(); - private static readonly object s_khakiKey = new object(); - private static readonly object s_lavenderKey = new object(); - private static readonly object s_lavenderBlushKey = new object(); - private static readonly object s_lawnGreenKey = new object(); - private static readonly object s_lemonChiffonKey = new object(); - private static readonly object s_lightBlueKey = new object(); - private static readonly object s_lightCoralKey = new object(); - private static readonly object s_lightCyanKey = new object(); - private static readonly object s_lightGoldenrodYellowKey = new object(); - private static readonly object s_lightGreenKey = new object(); - private static readonly object s_lightGrayKey = new object(); - private static readonly object s_lightPinkKey = new object(); - private static readonly object s_lightSalmonKey = new object(); - private static readonly object s_lightSeaGreenKey = new object(); - private static readonly object s_lightSkyBlueKey = new object(); - private static readonly object s_lightSlateGrayKey = new object(); - private static readonly object s_lightSteelBlueKey = new object(); - private static readonly object s_lightYellowKey = new object(); - private static readonly object s_limeKey = new object(); - private static readonly object s_limeGreenKey = new object(); - private static readonly object s_linenKey = new object(); - private static readonly object s_magentaKey = new object(); - private static readonly object s_maroonKey = new object(); - private static readonly object s_mediumAquamarineKey = new object(); - private static readonly object s_mediumBlueKey = new object(); - private static readonly object s_mediumOrchidKey = new object(); - private static readonly object s_mediumPurpleKey = new object(); - private static readonly object s_mediumSeaGreenKey = new object(); - private static readonly object s_mediumSlateBlueKey = new object(); - private static readonly object s_mediumSpringGreenKey = new object(); - private static readonly object s_mediumTurquoiseKey = new object(); - private static readonly object s_mediumVioletRedKey = new object(); - private static readonly object s_midnightBlueKey = new object(); - private static readonly object s_mintCreamKey = new object(); - private static readonly object s_mistyRoseKey = new object(); - private static readonly object s_moccasinKey = new object(); - private static readonly object s_navajoWhiteKey = new object(); - private static readonly object s_navyKey = new object(); - private static readonly object s_oldLaceKey = new object(); - private static readonly object s_oliveKey = new object(); - private static readonly object s_oliveDrabKey = new object(); - private static readonly object s_orangeKey = new object(); - private static readonly object s_orangeRedKey = new object(); - private static readonly object s_orchidKey = new object(); - private static readonly object s_paleGoldenrodKey = new object(); - private static readonly object s_paleGreenKey = new object(); - private static readonly object s_paleTurquoiseKey = new object(); - private static readonly object s_paleVioletRedKey = new object(); - private static readonly object s_papayaWhipKey = new object(); - private static readonly object s_peachPuffKey = new object(); - private static readonly object s_peruKey = new object(); - private static readonly object s_pinkKey = new object(); - private static readonly object s_plumKey = new object(); - private static readonly object s_powderBlueKey = new object(); - private static readonly object s_purpleKey = new object(); - private static readonly object s_redKey = new object(); - private static readonly object s_rosyBrownKey = new object(); - private static readonly object s_royalBlueKey = new object(); - private static readonly object s_saddleBrownKey = new object(); - private static readonly object s_salmonKey = new object(); - private static readonly object s_sandyBrownKey = new object(); - private static readonly object s_seaGreenKey = new object(); - private static readonly object s_seaShellKey = new object(); - private static readonly object s_siennaKey = new object(); - private static readonly object s_silverKey = new object(); - private static readonly object s_skyBlueKey = new object(); - private static readonly object s_slateBlueKey = new object(); - private static readonly object s_slateGrayKey = new object(); - private static readonly object s_snowKey = new object(); - private static readonly object s_springGreenKey = new object(); - private static readonly object s_steelBlueKey = new object(); - private static readonly object s_tanKey = new object(); - private static readonly object s_tealKey = new object(); - private static readonly object s_thistleKey = new object(); - private static readonly object s_tomatoKey = new object(); - private static readonly object s_turquoiseKey = new object(); - private static readonly object s_violetKey = new object(); - private static readonly object s_wheatKey = new object(); - private static readonly object s_whiteKey = new object(); - private static readonly object s_whiteSmokeKey = new object(); - private static readonly object s_yellowKey = new object(); - private static readonly object s_yellowGreenKey = new object(); + private static readonly object s_transparentKey = new(); + private static readonly object s_aliceBlueKey = new(); + private static readonly object s_antiqueWhiteKey = new(); + private static readonly object s_aquaKey = new(); + private static readonly object s_aquamarineKey = new(); + private static readonly object s_azureKey = new(); + private static readonly object s_beigeKey = new(); + private static readonly object s_bisqueKey = new(); + private static readonly object s_blackKey = new(); + private static readonly object s_blanchedAlmondKey = new(); + private static readonly object s_blueKey = new(); + private static readonly object s_blueVioletKey = new(); + private static readonly object s_brownKey = new(); + private static readonly object s_burlyWoodKey = new(); + private static readonly object s_cadetBlueKey = new(); + private static readonly object s_chartreuseKey = new(); + private static readonly object s_chocolateKey = new(); + private static readonly object s_coralKey = new(); + private static readonly object s_cornflowerBlueKey = new(); + private static readonly object s_cornsilkKey = new(); + private static readonly object s_crimsonKey = new(); + private static readonly object s_cyanKey = new(); + private static readonly object s_darkBlueKey = new(); + private static readonly object s_darkCyanKey = new(); + private static readonly object s_darkGoldenrodKey = new(); + private static readonly object s_darkGrayKey = new(); + private static readonly object s_darkGreenKey = new(); + private static readonly object s_darkKhakiKey = new(); + private static readonly object s_darkMagentaKey = new(); + private static readonly object s_darkOliveGreenKey = new(); + private static readonly object s_darkOrangeKey = new(); + private static readonly object s_darkOrchidKey = new(); + private static readonly object s_darkRedKey = new(); + private static readonly object s_darkSalmonKey = new(); + private static readonly object s_darkSeaGreenKey = new(); + private static readonly object s_darkSlateBlueKey = new(); + private static readonly object s_darkSlateGrayKey = new(); + private static readonly object s_darkTurquoiseKey = new(); + private static readonly object s_darkVioletKey = new(); + private static readonly object s_deepPinkKey = new(); + private static readonly object s_deepSkyBlueKey = new(); + private static readonly object s_dimGrayKey = new(); + private static readonly object s_dodgerBlueKey = new(); + private static readonly object s_firebrickKey = new(); + private static readonly object s_floralWhiteKey = new(); + private static readonly object s_forestGreenKey = new(); + private static readonly object s_fuchsiaKey = new(); + private static readonly object s_gainsboroKey = new(); + private static readonly object s_ghostWhiteKey = new(); + private static readonly object s_goldKey = new(); + private static readonly object s_goldenrodKey = new(); + private static readonly object s_grayKey = new(); + private static readonly object s_greenKey = new(); + private static readonly object s_greenYellowKey = new(); + private static readonly object s_honeydewKey = new(); + private static readonly object s_hotPinkKey = new(); + private static readonly object s_indianRedKey = new(); + private static readonly object s_indigoKey = new(); + private static readonly object s_ivoryKey = new(); + private static readonly object s_khakiKey = new(); + private static readonly object s_lavenderKey = new(); + private static readonly object s_lavenderBlushKey = new(); + private static readonly object s_lawnGreenKey = new(); + private static readonly object s_lemonChiffonKey = new(); + private static readonly object s_lightBlueKey = new(); + private static readonly object s_lightCoralKey = new(); + private static readonly object s_lightCyanKey = new(); + private static readonly object s_lightGoldenrodYellowKey = new(); + private static readonly object s_lightGreenKey = new(); + private static readonly object s_lightGrayKey = new(); + private static readonly object s_lightPinkKey = new(); + private static readonly object s_lightSalmonKey = new(); + private static readonly object s_lightSeaGreenKey = new(); + private static readonly object s_lightSkyBlueKey = new(); + private static readonly object s_lightSlateGrayKey = new(); + private static readonly object s_lightSteelBlueKey = new(); + private static readonly object s_lightYellowKey = new(); + private static readonly object s_limeKey = new(); + private static readonly object s_limeGreenKey = new(); + private static readonly object s_linenKey = new(); + private static readonly object s_magentaKey = new(); + private static readonly object s_maroonKey = new(); + private static readonly object s_mediumAquamarineKey = new(); + private static readonly object s_mediumBlueKey = new(); + private static readonly object s_mediumOrchidKey = new(); + private static readonly object s_mediumPurpleKey = new(); + private static readonly object s_mediumSeaGreenKey = new(); + private static readonly object s_mediumSlateBlueKey = new(); + private static readonly object s_mediumSpringGreenKey = new(); + private static readonly object s_mediumTurquoiseKey = new(); + private static readonly object s_mediumVioletRedKey = new(); + private static readonly object s_midnightBlueKey = new(); + private static readonly object s_mintCreamKey = new(); + private static readonly object s_mistyRoseKey = new(); + private static readonly object s_moccasinKey = new(); + private static readonly object s_navajoWhiteKey = new(); + private static readonly object s_navyKey = new(); + private static readonly object s_oldLaceKey = new(); + private static readonly object s_oliveKey = new(); + private static readonly object s_oliveDrabKey = new(); + private static readonly object s_orangeKey = new(); + private static readonly object s_orangeRedKey = new(); + private static readonly object s_orchidKey = new(); + private static readonly object s_paleGoldenrodKey = new(); + private static readonly object s_paleGreenKey = new(); + private static readonly object s_paleTurquoiseKey = new(); + private static readonly object s_paleVioletRedKey = new(); + private static readonly object s_papayaWhipKey = new(); + private static readonly object s_peachPuffKey = new(); + private static readonly object s_peruKey = new(); + private static readonly object s_pinkKey = new(); + private static readonly object s_plumKey = new(); + private static readonly object s_powderBlueKey = new(); + private static readonly object s_purpleKey = new(); + private static readonly object s_redKey = new(); + private static readonly object s_rosyBrownKey = new(); + private static readonly object s_royalBlueKey = new(); + private static readonly object s_saddleBrownKey = new(); + private static readonly object s_salmonKey = new(); + private static readonly object s_sandyBrownKey = new(); + private static readonly object s_seaGreenKey = new(); + private static readonly object s_seaShellKey = new(); + private static readonly object s_siennaKey = new(); + private static readonly object s_silverKey = new(); + private static readonly object s_skyBlueKey = new(); + private static readonly object s_slateBlueKey = new(); + private static readonly object s_slateGrayKey = new(); + private static readonly object s_snowKey = new(); + private static readonly object s_springGreenKey = new(); + private static readonly object s_steelBlueKey = new(); + private static readonly object s_tanKey = new(); + private static readonly object s_tealKey = new(); + private static readonly object s_thistleKey = new(); + private static readonly object s_tomatoKey = new(); + private static readonly object s_turquoiseKey = new(); + private static readonly object s_violetKey = new(); + private static readonly object s_wheatKey = new(); + private static readonly object s_whiteKey = new(); + private static readonly object s_whiteSmokeKey = new(); + private static readonly object s_yellowKey = new(); + private static readonly object s_yellowGreenKey = new(); public static Pen Transparent => GetPen(s_transparentKey, Color.Transparent); diff --git a/src/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs b/src/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs index 4d1abe68d7f..018b2e94253 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs @@ -19,7 +19,7 @@ public partial class PageSettings : ICloneable private PaperSource? _paperSource; private PrinterResolution? _printerResolution; private TriState _landscape = TriState.Default; - private Margins _margins = new Margins(); + private Margins _margins = new(); /// /// Initializes a new instance of the class using the default printer. diff --git a/src/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs b/src/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs index d92da4fa812..77ae1b7a6e1 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs @@ -18,7 +18,7 @@ public class PreviewPrintController : PrintController { private Graphics? _graphics; private DeviceContext? _dc; - private readonly ArrayList _list = new ArrayList(); + private readonly ArrayList _list = new(); public override bool IsPreview => true; diff --git a/src/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs b/src/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs index 3069f5d3b6c..2352807de2d 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs @@ -18,7 +18,7 @@ public class PrintDocument : Component private PrintPageEventHandler? _printPageHandler; private QueryPageSettingsEventHandler? _queryHandler; - private PrinterSettings _printerSettings = new PrinterSettings(); + private PrinterSettings _printerSettings = new(); private PageSettings _defaultPageSettings; private PrintController? _printController; diff --git a/src/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs b/src/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs index 165d9afe747..fcf08ce7a11 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs @@ -7,9 +7,9 @@ namespace System.Drawing.Printing; { private readonly byte _value; // 0 is "default", not false - public static readonly TriState Default = new TriState(0); - public static readonly TriState False = new TriState(1); - public static readonly TriState True = new TriState(2); + public static readonly TriState Default = new(0); + public static readonly TriState False = new(1); + public static readonly TriState True = new(2); private TriState(byte value) => _value = value; diff --git a/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs b/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs index db6efb31356..95f0f0e4021 100644 --- a/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs +++ b/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs @@ -10,5 +10,5 @@ internal unsafe struct PropertyItemInternal public short type; public byte* value; - public Span Value => new Span(value, len); + public Span Value => new(value, len); } diff --git a/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs b/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs index 2d7bc9d92c3..5c28158d5e6 100644 --- a/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs +++ b/src/System.Drawing.Common/src/System/Drawing/ScreenDC.cs @@ -12,7 +12,7 @@ internal struct ScreenDC : IDisposable { private IntPtr _handle; - public static ScreenDC Create() => new ScreenDC + public static ScreenDC Create() => new() { _handle = User32.GetDC(IntPtr.Zero) }; diff --git a/src/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs b/src/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs index 4e5f0f0a407..f1413e9e429 100644 --- a/src/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs +++ b/src/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs @@ -7,7 +7,7 @@ namespace System.Drawing; public static class SystemBrushes { - private static readonly object s_systemBrushesKey = new object(); + private static readonly object s_systemBrushesKey = new(); public static Brush ActiveBorder => FromSystemColor(SystemColors.ActiveBorder); public static Brush ActiveCaption => FromSystemColor(SystemColors.ActiveCaption); diff --git a/src/System.Drawing.Common/src/System/Drawing/SystemPens.cs b/src/System.Drawing.Common/src/System/Drawing/SystemPens.cs index 28bded2e633..af01ce3c9ba 100644 --- a/src/System.Drawing.Common/src/System/Drawing/SystemPens.cs +++ b/src/System.Drawing.Common/src/System/Drawing/SystemPens.cs @@ -7,7 +7,7 @@ namespace System.Drawing; public static class SystemPens { - private static readonly object s_systemPensKey = new object(); + private static readonly object s_systemPensKey = new(); public static Pen ActiveBorder => FromSystemColor(SystemColors.ActiveBorder); public static Pen ActiveCaption => FromSystemColor(SystemColors.ActiveCaption); diff --git a/src/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs b/src/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs index f356a0ab850..da02d165c21 100644 --- a/src/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs +++ b/src/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs @@ -23,8 +23,8 @@ public class ToolboxBitmapAttribute : Attribute private readonly string? _imageName; - private static readonly Size s_largeSize = new Size(32, 32); - private static readonly Size s_smallSize = new Size(16, 16); + private static readonly Size s_largeSize = new(32, 32); + private static readonly Size s_smallSize = new(16, 16); public ToolboxBitmapAttribute(string imageFile) : this(GetImageFromFile(imageFile, false), GetImageFromFile(imageFile, true)) { @@ -306,7 +306,7 @@ private static void MakeBackgroundAlphaZero(Bitmap img) img.SetPixel(0, img.Height - 1, newBottomLeft); } - public static readonly ToolboxBitmapAttribute Default = new ToolboxBitmapAttribute(null, (Image?)null); + public static readonly ToolboxBitmapAttribute Default = new(null, (Image?)null); private static readonly ToolboxBitmapAttribute s_defaultComponent; diff --git a/src/System.Drawing.Common/src/misc/DbgUtil.cs b/src/System.Drawing.Common/src/misc/DbgUtil.cs index 93f5e714c0f..0c4f303d1e6 100644 --- a/src/System.Drawing.Common/src/misc/DbgUtil.cs +++ b/src/System.Drawing.Common/src/misc/DbgUtil.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; @@ -56,7 +56,7 @@ public static void AssertWin32(bool expression, string format, params object[] a { if (!expression) { - var e = new Win32Exception(); + Win32Exception e = new(); string message = string.Format(CultureInfo.CurrentCulture, format, args); Debug.Fail($"{message}\r\nError: 0x{e.NativeErrorCode:x8} - {e.Message}"); } diff --git a/src/System.Drawing.Common/tests/BitmapTests.cs b/src/System.Drawing.Common/tests/BitmapTests.cs index b03e01bf7e4..f429838ce85 100644 --- a/src/System.Drawing.Common/tests/BitmapTests.cs +++ b/src/System.Drawing.Common/tests/BitmapTests.cs @@ -1093,7 +1093,7 @@ public void SetResolution_Disposed_ThrowsArgumentException() public static IEnumerable LockBits_TestData() { - Bitmap bitmap() => new Bitmap(2, 2, PixelFormat.Format32bppArgb); + Bitmap bitmap() => new(2, 2, PixelFormat.Format32bppArgb); yield return new object[] { bitmap(), new Rectangle(0, 0, 2, 2), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb, 8, 1 }; yield return new object[] { bitmap(), new Rectangle(0, 0, 2, 2), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb, 8, 3 }; yield return new object[] { bitmap(), new Rectangle(0, 0, 2, 2), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb, 8, 2 }; diff --git a/src/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs b/src/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs index 4a02a26dff8..e302b52623c 100644 --- a/src/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs +++ b/src/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs @@ -78,7 +78,7 @@ public void Ctor_Elements(float m11, float m12, float m21, float m22, float dx, } public static TheoryData MatrixElements_TestData - => new TheoryData + => new() { { 1, 0, 0, 1, 0, 0, true, true }, { 0, 1, 2, 1, 3, 4, false, true }, diff --git a/src/System.Drawing.Common/tests/Drawing2D/PathGradientBrushTests.cs b/src/System.Drawing.Common/tests/Drawing2D/PathGradientBrushTests.cs index ea0073f8fbd..a329ae6c352 100644 --- a/src/System.Drawing.Common/tests/Drawing2D/PathGradientBrushTests.cs +++ b/src/System.Drawing.Common/tests/Drawing2D/PathGradientBrushTests.cs @@ -29,7 +29,7 @@ public class PathGradientBrushTests { private readonly Point[] _defaultIntPoints = new Point[2] { new Point(1, 2), new Point(20, 30) }; private readonly PointF[] _defaultFloatPoints = new PointF[2] { new PointF(1, 2), new PointF(20, 30) }; - private readonly RectangleF _defaultRectangle = new RectangleF(1, 2, 19, 28); + private readonly RectangleF _defaultRectangle = new(1, 2, 19, 28); [Fact] public void Ctor_Points_ReturnsExpected() diff --git a/src/System.Drawing.Common/tests/ImageTests.cs b/src/System.Drawing.Common/tests/ImageTests.cs index ff0082687da..7b25bae6adc 100644 --- a/src/System.Drawing.Common/tests/ImageTests.cs +++ b/src/System.Drawing.Common/tests/ImageTests.cs @@ -519,7 +519,7 @@ public void FromFile_LongSegment_ThrowsException() // Throws PathTooLongException on Desktop and FileNotFoundException elsewhere. if (PlatformDetection.IsNetFramework) { - string fileName = new string('a', 261); + string fileName = new('a', 261); Assert.Throws(() => Image.FromFile(fileName)); Assert.Throws(() => Image.FromFile(fileName, @@ -527,7 +527,7 @@ public void FromFile_LongSegment_ThrowsException() } else { - string fileName = new string('a', 261); + string fileName = new('a', 261); Assert.Throws(() => Image.FromFile(fileName)); Assert.Throws(() => Image.FromFile(fileName, diff --git a/src/System.Drawing.Common/tests/Imaging/ImageAttributesTests.cs b/src/System.Drawing.Common/tests/Imaging/ImageAttributesTests.cs index 8802f943c64..f87327c82b4 100644 --- a/src/System.Drawing.Common/tests/Imaging/ImageAttributesTests.cs +++ b/src/System.Drawing.Common/tests/Imaging/ImageAttributesTests.cs @@ -29,12 +29,12 @@ namespace System.Drawing.Imaging.Tests; public class ImageAttributesTests { - private readonly Rectangle _rectangle = new Rectangle(0, 0, 64, 64); + private readonly Rectangle _rectangle = new(0, 0, 64, 64); private readonly Color _actualYellow = Color.FromArgb(255, 255, 255, 0); private readonly Color _actualGreen = Color.FromArgb(255, 0, 255, 0); private readonly Color _expectedRed = Color.FromArgb(255, 255, 0, 0); private readonly Color _expectedBlack = Color.FromArgb(255, 0, 0, 0); - private readonly ColorMatrix _greenComponentToZeroColorMatrix = new ColorMatrix(new float[][] + private readonly ColorMatrix _greenComponentToZeroColorMatrix = new(new float[][] { new float[] {1, 0, 0, 0, 0}, new float[] {0, 0, 0, 0, 0}, @@ -43,7 +43,7 @@ public class ImageAttributesTests new float[] {0, 0, 0, 0, 0}, }); - private readonly ColorMatrix _grayMatrix = new ColorMatrix(new float[][] { + private readonly ColorMatrix _grayMatrix = new(new float[][] { new float[] {1, 0, 0, 0, 0}, new float[] {0, 2, 0, 0, 0}, new float[] {0, 0, 3, 0, 0}, @@ -1215,7 +1215,7 @@ public void SetOutputChannelColorProfile_InvalidPath_ThrowsOutOfMemoryException( [Fact] public void SetOutputChannelColorProfile_InvalidPath_ThrowsPathTooLongException() { - string fileNameTooLong = new string('a', short.MaxValue); + string fileNameTooLong = new('a', short.MaxValue); using (var imageAttr = new ImageAttributes()) { Assert.Throws(() => imageAttr.SetOutputChannelColorProfile(fileNameTooLong)); diff --git a/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs b/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs index d5292c83a27..2845c4bd09b 100644 --- a/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs +++ b/src/System.Drawing.Common/tests/Imaging/ImageFormatTests.cs @@ -5,19 +5,19 @@ namespace System.Drawing.Imaging.Tests; public class ImageFormatTests { - private static ImageFormat BmpImageFormat = new ImageFormat(new Guid("b96b3cab-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat EmfImageFormat = new ImageFormat(new Guid("b96b3cac-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat ExifImageFormat = new ImageFormat(new Guid("b96b3cb2-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat GifImageFormat = new ImageFormat(new Guid("b96b3cb0-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat TiffImageFormat = new ImageFormat(new Guid("b96b3cb1-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat PngImageFormat = new ImageFormat(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat MemoryBmpImageFormat = new ImageFormat(new Guid("b96b3caa-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat IconImageFormat = new ImageFormat(new Guid("b96b3cb5-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat JpegImageFormat = new ImageFormat(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat WmfImageFormat = new ImageFormat(new Guid("b96b3cad-0728-11d3-9d7b-0000f81ef32e")); - private static ImageFormat HeifImageFormat = new ImageFormat(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}")); - private static ImageFormat WebpImageFormat = new ImageFormat(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}")); - private static ImageFormat CustomImageFormat = new ImageFormat(new Guid("48749428-316f-496a-ab30-c819a92b3137")); + private static ImageFormat BmpImageFormat = new(new Guid("b96b3cab-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat EmfImageFormat = new(new Guid("b96b3cac-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat ExifImageFormat = new(new Guid("b96b3cb2-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat GifImageFormat = new(new Guid("b96b3cb0-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat TiffImageFormat = new(new Guid("b96b3cb1-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat PngImageFormat = new(new Guid("b96b3caf-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat MemoryBmpImageFormat = new(new Guid("b96b3caa-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat IconImageFormat = new(new Guid("b96b3cb5-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat JpegImageFormat = new(new Guid("b96b3cae-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat WmfImageFormat = new(new Guid("b96b3cad-0728-11d3-9d7b-0000f81ef32e")); + private static ImageFormat HeifImageFormat = new(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}")); + private static ImageFormat WebpImageFormat = new(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}")); + private static ImageFormat CustomImageFormat = new(new Guid("48749428-316f-496a-ab30-c819a92b3137")); public static IEnumerable ImageFormatGuidTestData { diff --git a/src/System.Drawing.Common/tests/Imaging/MetafileTests.cs b/src/System.Drawing.Common/tests/Imaging/MetafileTests.cs index 454ac5b7e62..9274ea35438 100644 --- a/src/System.Drawing.Common/tests/Imaging/MetafileTests.cs +++ b/src/System.Drawing.Common/tests/Imaging/MetafileTests.cs @@ -31,8 +31,8 @@ public class MetafileTests { private const string WmfFile = "telescope_01.wmf"; private const string BmpFile = "bitmap_173x183_indexed_8bit.bmp"; - private readonly Rectangle _rectangle = new Rectangle(0, 0, 64, 64); - private readonly RectangleF _rectangleF = new RectangleF(0, 0, 64, 64); + private readonly Rectangle _rectangle = new(0, 0, 64, 64); + private readonly RectangleF _rectangleF = new(0, 0, 64, 64); [Fact] public void Ctor_IntPtrZero_ThrowsArgumentException() diff --git a/src/System.Drawing.Common/tests/Printing/PrintDocumentTests.cs b/src/System.Drawing.Common/tests/Printing/PrintDocumentTests.cs index 97d0d4a4694..9af2b3e48e7 100644 --- a/src/System.Drawing.Common/tests/Printing/PrintDocumentTests.cs +++ b/src/System.Drawing.Common/tests/Printing/PrintDocumentTests.cs @@ -27,7 +27,7 @@ namespace System.Drawing.Printing.Tests; public class PrintDocumentTests : FileCleanupTestBase { - private readonly PageSettings _pageSettings = new PageSettings() + private readonly PageSettings _pageSettings = new() { PaperSize = new PaperSize() { diff --git a/src/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs b/src/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs index 1dcdfd677e6..083f7a4ef7a 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs @@ -195,7 +195,7 @@ private static bool EmptyFontPresent } } - public static TheoryData ArgumentExceptionFontConverterData() => new TheoryData() + public static TheoryData ArgumentExceptionFontConverterData() => new() { { $"Courier New{s_separator} 11 px{s_separator} type=Bold{s_separator} Italic", "units", null }, { $"Courier New{s_separator} {s_separator} Style=Bold", "value", null }, @@ -209,7 +209,7 @@ private static bool EmptyFontPresent { $"Arial{s_separator} 10style{s_separator} style=bold", "units", null }, }; - public static TheoryData InvalidEnumArgumentExceptionFontConverterData() => new TheoryData() + public static TheoryData InvalidEnumArgumentExceptionFontConverterData() => new() { { $"Arial{s_separator} 10{s_separator} style=56", "style" }, { $"Arial{s_separator} 10{s_separator} style=-1", "style" }, diff --git a/src/System.Drawing.Common/tests/ToolboxBitmapAttributeTests.cs b/src/System.Drawing.Common/tests/ToolboxBitmapAttributeTests.cs index 368d0ab4ba2..7b9e3438920 100644 --- a/src/System.Drawing.Common/tests/ToolboxBitmapAttributeTests.cs +++ b/src/System.Drawing.Common/tests/ToolboxBitmapAttributeTests.cs @@ -14,7 +14,7 @@ public class Icon_toolboxBitmapAttributeTest { } public class ToolboxBitmapAttributeTests { - private static Size DefaultSize = new Size(16, 16); + private static Size DefaultSize = new(16, 16); private void AssertDefaultSize(Image image) { Assert.Equal(DefaultSize, image.Size); diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs index 1e07283dc5c..8bbc3ff3ddf 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ByteViewer.cs @@ -37,8 +37,8 @@ public class ByteViewer : TableLayoutPanel private const int DUMP_START_X = HEX_START_X + HEX_WIDTH + HEX_DUMP_GAP; private const int SCROLLBAR_START_X = DUMP_START_X + DUMP_WIDTH + HEX_DUMP_GAP; - private static readonly Font ADDRESS_FONT = new Font("Microsoft Sans Serif", 8.0f); - private static readonly Font HEXDUMP_FONT = new Font("Courier New", 8.0f); + private static readonly Font ADDRESS_FONT = new("Microsoft Sans Serif", 8.0f); + private static readonly Font HEXDUMP_FONT = new("Courier New", 8.0f); private int SCROLLBAR_HEIGHT; private int SCROLLBAR_WIDTH; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs index ba69f2812d1..96853c277a8 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignSurfaceManager.cs @@ -272,7 +272,7 @@ public DesignSurface CreateDesignSurface(IServiceProvider parentProvider) /// Creates an instance of a design surface. This can be /// overridden to provide a derived version of DesignSurface. /// - protected virtual DesignSurface CreateDesignSurfaceCore(IServiceProvider parentProvider) => new DesignSurface(parentProvider); + protected virtual DesignSurface CreateDesignSurfaceCore(IServiceProvider parentProvider) => new(parentProvider); /// /// Disposes the designer application. diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs index 29a4ee2ff1e..4854b3bdaae 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.HeaderLine.cs @@ -14,6 +14,6 @@ public HeaderLine(IServiceProvider serviceProvider, DesignerActionPanel actionPa { } - protected override Font GetFont() => new Font(ActionPanel.Font, FontStyle.Bold); + protected override Font GetFont() => new(ActionPanel.Font, FontStyle.Bold); } } diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs index 1aa6ee69246..75b6b5959f0 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.SeparatorLine.cs @@ -34,7 +34,7 @@ protected override void AddControls(List controls) public sealed override void Focus() => Debug.Fail("Should never try to focus a SeparatorLine"); - public override Size LayoutControls(int top, int width, bool measureOnly) => new Size(MinimumWidth, 1); + public override Size LayoutControls(int top, int width, bool measureOnly) => new(MinimumWidth, 1); public override void PaintLine(Graphics g, int lineWidth, int lineHeight) { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs index c54862bbdfe..d92d02ab1e4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs @@ -17,8 +17,8 @@ namespace System.ComponentModel.Design; internal sealed partial class DesignerActionPanel : ContainerControl { - private static readonly object s_eventFormActivated = new object(); - private static readonly object s_eventFormDeactivate = new object(); + private static readonly object s_eventFormActivated = new(); + private static readonly object s_eventFormDeactivate = new(); private const int EditInputWidth = 150; // The static size of edit controls private const int ListBoxMaximumHeight = 200; // The maximum height of a dropdown listbox diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs index 6fa1a5b7856..a53035d3d92 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionUI.cs @@ -24,7 +24,7 @@ namespace System.ComponentModel.Design; /// internal partial class DesignerActionUI : IDisposable { - private static readonly TraceSwitch s_designerActionPanelTraceSwitch = new TraceSwitch("DesignerActionPanelTrace", "DesignerActionPanel tracing"); + private static readonly TraceSwitch s_designerActionPanelTraceSwitch = new("DesignerActionPanelTrace", "DesignerActionPanel tracing"); private Adorner _designerActionAdorner; //used to add designeraction-related glyphs private IServiceProvider _serviceProvider; //standard service provider @@ -52,7 +52,7 @@ internal partial class DesignerActionUI : IDisposable private delegate void ActionChangedEventHandler(object sender, DesignerActionListsChangedEventArgs e); #if DEBUG - internal static readonly TraceSwitch DropDownVisibilityDebug = new TraceSwitch("DropDownVisibilityDebug", "Debug ToolStrip Selection code"); + internal static readonly TraceSwitch DropDownVisibilityDebug = new("DropDownVisibilityDebug", "Debug ToolStrip Selection code"); #else internal static readonly TraceSwitch DropDownVisibilityDebug; #endif diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs index ca0d423765f..8f022aeb53c 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerEventService.cs @@ -12,10 +12,10 @@ namespace System.ComponentModel.Design; /// internal sealed class DesignerEventService : IDesignerEventService { - private static readonly object s_eventActiveDesignerChanged = new object(); - private static readonly object s_eventDesignerCreated = new object(); - private static readonly object s_eventDesignerDisposed = new object(); - private static readonly object s_eventSelectionChanged = new object(); + private static readonly object s_eventActiveDesignerChanged = new(); + private static readonly object s_eventDesignerCreated = new(); + private static readonly object s_eventDesignerDisposed = new(); + private static readonly object s_eventSelectionChanged = new(); private List? _designerList; // read write list used as data for the collection private DesignerCollection? _designerCollection; // public read only view of the above list diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs index 9dedba779a3..ed9db1b2b18 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerHost.cs @@ -23,22 +23,22 @@ internal sealed partial class DesignerHost : Container, IDesignerLoaderHost2, ID private static readonly Type[] s_defaultServices = new Type[] { typeof(IDesignerHost), typeof(IContainer), typeof(IComponentChangeService), typeof(IDesignerLoaderHost2) }; // IDesignerHost events - private static readonly object s_eventActivated = new object(); // Designer has been activated - private static readonly object s_eventDeactivated = new object(); // Designer has been deactivated - private static readonly object s_eventLoadComplete = new object(); // Loading has been completed - private static readonly object s_eventTransactionClosed = new object(); // The last transaction has been closed - private static readonly object s_eventTransactionClosing = new object(); // The last transaction is about to be closed - private static readonly object s_eventTransactionOpened = new object(); // The first transaction has been opened - private static readonly object s_eventTransactionOpening = new object(); // The first transaction is about to be opened + private static readonly object s_eventActivated = new(); // Designer has been activated + private static readonly object s_eventDeactivated = new(); // Designer has been deactivated + private static readonly object s_eventLoadComplete = new(); // Loading has been completed + private static readonly object s_eventTransactionClosed = new(); // The last transaction has been closed + private static readonly object s_eventTransactionClosing = new(); // The last transaction is about to be closed + private static readonly object s_eventTransactionOpened = new(); // The first transaction has been opened + private static readonly object s_eventTransactionOpening = new(); // The first transaction is about to be opened // IComponentChangeService events - private static readonly object s_eventComponentAdding = new object(); // A component is about to be added to the container - private static readonly object s_eventComponentAdded = new object(); // A component was just added to the container - private static readonly object s_eventComponentChanging = new object(); // A component is about to be changed - private static readonly object s_eventComponentChanged = new object(); // A component has changed - private static readonly object s_eventComponentRemoving = new object(); // A component is about to be removed from the container - private static readonly object s_eventComponentRemoved = new object(); // A component has been removed from the container - private static readonly object s_eventComponentRename = new object(); // A component has been renamed + private static readonly object s_eventComponentAdding = new(); // A component is about to be added to the container + private static readonly object s_eventComponentAdded = new(); // A component was just added to the container + private static readonly object s_eventComponentChanging = new(); // A component is about to be changed + private static readonly object s_eventComponentChanged = new(); // A component has changed + private static readonly object s_eventComponentRemoving = new(); // A component is about to be removed from the container + private static readonly object s_eventComponentRemoved = new(); // A component has been removed from the container + private static readonly object s_eventComponentRename = new(); // A component has been renamed // Member variables private BitVector32 _state; // state for this host @@ -53,7 +53,7 @@ internal sealed partial class DesignerHost : Container, IDesignerLoaderHost2, ID private List? _savedSelection; // set of selected components names saved across reloads private HostDesigntimeLicenseContext? _licenseCtx; private IDesignerEventService? _designerEventService; - private static readonly object s_selfLock = new object(); + private static readonly object s_selfLock = new(); private bool _ignoreErrorsDuringReload; private TypeDescriptionProviderService? _typeService; private bool _typeServiceChecked; @@ -61,7 +61,7 @@ internal sealed partial class DesignerHost : Container, IDesignerLoaderHost2, ID public DesignerHost(DesignSurface surface) { _surface = surface; - _state = default(BitVector32); + _state = default; _designers = new(); _events = new EventHandlerList(); diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs index 274737ba173..cbdefffa118 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritanceService.cs @@ -16,7 +16,7 @@ namespace System.ComponentModel.Design; /// public class InheritanceService : IInheritanceService, IDisposable { - private static readonly TraceSwitch s_inheritanceServiceSwitch = new TraceSwitch("InheritanceService", "InheritanceService : Debug inheritance scan."); + private static readonly TraceSwitch s_inheritanceServiceSwitch = new("InheritanceService", "InheritanceService : Debug inheritance scan."); private Dictionary _inheritedComponents; // While we're adding an inherited component, we must be wary of components that the inherited component adds as a result of being sited. These are treated as inherited as well. To track these, we keep track of the component we're currently adding as well as it's inheritance attribute. During the add, we sync IComponentAdding events and push in the component private IComponent _addingComponent; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs index cc9a3294af1..f009362932c 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/InheritedPropertyDescriptor.cs @@ -18,7 +18,7 @@ internal sealed class InheritedPropertyDescriptor : PropertyDescriptor { private PropertyDescriptor propertyDescriptor; private object _defaultValue; - private static readonly object s_noDefault = new object(); + private static readonly object s_noDefault = new(); private bool _initShouldSerialize; private object _originalValue; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs index 906413b5302..fbaf0084389 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/MenuCommandService.cs @@ -26,7 +26,7 @@ public class MenuCommandService : IMenuCommandService, IDisposable private List _globalVerbs; private ISelectionService _selectionService; - internal static TraceSwitch MENUSERVICE = new TraceSwitch("MENUSERVICE", "MenuCommandService: Track menu command routing"); + internal static TraceSwitch MENUSERVICE = new("MENUSERVICE", "MenuCommandService: Track menu command routing"); // This is the set of verbs we offer through the Verbs property. // It consists of the global verbs + any verbs that the currently diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs index 99227ccddc0..e3b6ad944b4 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/SelectionService.cs @@ -26,8 +26,8 @@ internal sealed class SelectionService : ISelectionService, IDisposable private static readonly int s_stateTransactionChange = BitVector32.CreateMask(s_stateTransaction); // Component change occurred while in a transaction // ISelectionService events - private static readonly object s_eventSelectionChanging = new object(); - private static readonly object s_eventSelectionChanged = new object(); + private static readonly object s_eventSelectionChanging = new(); + private static readonly object s_eventSelectionChanged = new(); // Member variables private IServiceProvider _provider; // The service provider diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs index d207af8fb66..7b1ebe1ba69 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomComponentSerializationService.cs @@ -176,7 +176,7 @@ public override void DeserializeTo(SerializationStore store, IContainer containe private sealed class CodeDomSerializationStore : SerializationStore, ISerializable { #if DEBUG - private static readonly TraceSwitch s_trace = new TraceSwitch("ComponentSerializationService", "Trace component serialization"); + private static readonly TraceSwitch s_trace = new("ComponentSerializationService", "Trace component serialization"); #else #pragma warning disable CS0649 private static readonly TraceSwitch s_trace; @@ -607,12 +607,12 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex /// private class ComponentListCodeDomSerializer : CodeDomSerializer { - internal static ComponentListCodeDomSerializer s_instance = new ComponentListCodeDomSerializer(); + internal static ComponentListCodeDomSerializer s_instance = new(); private Hashtable _statementsTable; private Dictionary> _expressions; private Hashtable _objectState; // only used during deserialization private bool _applyDefaults = true; - private readonly Hashtable _nameResolveGuard = new Hashtable(); + private readonly Hashtable _nameResolveGuard = new(); public override object Deserialize(IDesignerSerializationManager manager, object state) { @@ -1464,7 +1464,7 @@ object IServiceProvider.GetService(Type serviceType) private class PassThroughSerializationManager : IDesignerSerializationManager { - private readonly Hashtable _resolved = new Hashtable(); + private readonly Hashtable _resolved = new(); private readonly DesignerSerializationManager _manager; private ResolveNameEventHandler _resolveNameEventHandler; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs index 8c53a74bcf9..431c7e6aa5a 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomDesignerLoader.cs @@ -31,7 +31,7 @@ namespace System.ComponentModel.Design.Serialization; /// public abstract partial class CodeDomDesignerLoader : BasicDesignerLoader, INameCreationService, IDesignerSerializationService { - private static readonly TraceSwitch s_traceCDLoader = new TraceSwitch("CodeDomDesignerLoader", "Trace CodeDomDesignerLoader"); + private static readonly TraceSwitch s_traceCDLoader = new("CodeDomDesignerLoader", "Trace CodeDomDesignerLoader"); private static readonly int s_stateCodeDomDirty = BitVector32.CreateMask(); // True if the code dom tree is dirty, meaning it must be integrated back with the code file. private static readonly int s_stateCodeParserChecked = BitVector32.CreateMask(s_stateCodeDomDirty); // True if we have searched for a parser. private static readonly int s_stateOwnTypeResolution = BitVector32.CreateMask(s_stateCodeParserChecked); // True if we have added our own type resolution service diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs index 786893c0706..c493c62953e 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializer.cs @@ -18,7 +18,7 @@ public class CodeDomSerializer : CodeDomSerializerBase private static CodeDomSerializer s_default; private static readonly Attribute[] _runTimeFilter = new Attribute[] { DesignOnlyAttribute.No }; private static readonly Attribute[] _designTimeFilter = new Attribute[] { DesignOnlyAttribute.Yes }; - private static readonly CodeThisReferenceExpression _thisRef = new CodeThisReferenceExpression(); + private static readonly CodeThisReferenceExpression _thisRef = new(); internal static CodeDomSerializer Default { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs index c9b2b3e0dcf..5b8607abb4f 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/CodeDomSerializerBase.cs @@ -20,7 +20,7 @@ namespace System.ComponentModel.Design.Serialization; public abstract partial class CodeDomSerializerBase { private static readonly Attribute[] runTimeProperties = new Attribute[] { DesignOnlyAttribute.No }; - private static readonly TraceSwitch traceSerialization = new TraceSwitch("DesignerSerialization", "Trace design time serialization"); + private static readonly TraceSwitch traceSerialization = new("DesignerSerialization", "Trace design time serialization"); #pragma warning disable CS0649 private static Stack? traceScope; #pragma warning restore CS0649 diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentTypeCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentTypeCodeDomSerializer.cs index fd32e9f29e9..c689ba46114 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentTypeCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ComponentTypeCodeDomSerializer.cs @@ -13,7 +13,7 @@ namespace System.ComponentModel.Design.Serialization; /// internal class ComponentTypeCodeDomSerializer : TypeCodeDomSerializer { - private static readonly object _initMethodKey = new object(); + private static readonly object _initMethodKey = new(); private const string _initMethodName = "InitializeComponent"; private static ComponentTypeCodeDomSerializer s_default; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs index d3d52a38158..c74c2c3ebd2 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/EventMemberCodeDomSerializer.cs @@ -14,7 +14,7 @@ namespace System.ComponentModel.Design.Serialization; /// internal sealed class EventMemberCodeDomSerializer : MemberCodeDomSerializer { - private static readonly CodeThisReferenceExpression _thisRef = new CodeThisReferenceExpression(); + private static readonly CodeThisReferenceExpression _thisRef = new(); private static EventMemberCodeDomSerializer s_default; internal static EventMemberCodeDomSerializer Default diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.SerializationResourceManager.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.SerializationResourceManager.cs index a9fda53c87f..5ee8e8c06b5 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.SerializationResourceManager.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/ResourceCodeDomSerializer.SerializationResourceManager.cs @@ -19,7 +19,7 @@ internal partial class ResourceCodeDomSerializer /// internal class SerializationResourceManager : ComponentResourceManager { - private static readonly Dictionary s_resourceSetSentinel = new Dictionary(); + private static readonly Dictionary s_resourceSetSentinel = new(); private readonly IDesignerSerializationManager _manager; private bool _checkedLocalizationLanguage; private CultureInfo _localizationLanguage; diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/TypeCodeDomSerializer.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/TypeCodeDomSerializer.cs index 261d7ca17a2..f539d2a6db7 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/TypeCodeDomSerializer.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/Serialization/TypeCodeDomSerializer.cs @@ -21,7 +21,7 @@ public class TypeCodeDomSerializer : CodeDomSerializerBase private IDictionary _nameTable; private Dictionary _statementTable; private static readonly Attribute[] s_designTimeFilter = new Attribute[] { DesignOnlyAttribute.Yes }; - private static readonly object s_initMethodKey = new object(); + private static readonly object s_initMethodKey = new(); private static TypeCodeDomSerializer s_default; internal static TypeCodeDomSerializer Default @@ -582,7 +582,7 @@ private void IntegrateStatements(IDesignerSerializationManager manager, object r #region OrderedStatementsCollection Class private class StatementOrderComparer : IComparer { - public static readonly StatementOrderComparer s_default = new StatementOrderComparer(); + public static readonly StatementOrderComparer s_default = new(); private StatementOrderComparer() { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.cs index 421f262de5d..3e934205c2d 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/UndoEngine.cs @@ -21,7 +21,7 @@ namespace System.ComponentModel.Design; /// public abstract class UndoEngine : IDisposable { - private static readonly TraceSwitch s_traceUndo = new TraceSwitch("UndoEngine", "Trace UndoRedo"); + private static readonly TraceSwitch s_traceUndo = new("UndoEngine", "Trace UndoRedo"); private IServiceProvider _provider; private readonly Stack _unitStack; // the stack of active (non-committed) units. @@ -1168,7 +1168,7 @@ public ChangeUndoEvent(UndoEngine engine, ComponentChangingEventArgs e, bool ser public ComponentChangingEventArgs ComponentChangingEventArgs { - get => new ComponentChangingEventArgs(_openComponent, _member); + get => new(_openComponent, _member); } /// diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/BitmapEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/BitmapEditor.cs index 955d1f5e675..190a1243383 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/BitmapEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/BitmapEditor.cs @@ -11,7 +11,7 @@ namespace System.Drawing.Design; [CLSCompliant(false)] public class BitmapEditor : ImageEditor { - protected static List BitmapExtensions = new List() { "bmp", "gif", "jpg", "jpeg", "png", "ico" }; + protected static List BitmapExtensions = new() { "bmp", "gif", "jpg", "jpeg", "png", "ico" }; protected override string GetFileDialogDescription() => SR.bitmapFileDescription; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs index 6fd4f26573c..8d00c05786d 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/IconEditor.cs @@ -16,7 +16,7 @@ namespace System.Drawing.Design; /// public class IconEditor : UITypeEditor { - private static readonly List s_iconExtensions = new List() { "ico" }; + private static readonly List s_iconExtensions = new() { "ico" }; private static readonly Type[] s_imageExtenders = Array.Empty(); private FileDialog? _fileDialog; diff --git a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs index e29269598bb..b7000310ec3 100644 --- a/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Drawing/Design/ToolboxItem.cs @@ -18,7 +18,7 @@ namespace System.Drawing.Design; /// public class ToolboxItem : ISerializable { - private static readonly TraceSwitch s_toolboxItemPersist = new TraceSwitch("ToolboxPersisting", "ToolboxItem: write data"); + private static readonly TraceSwitch s_toolboxItemPersist = new("ToolboxPersisting", "ToolboxItem: write data"); private static bool s_isScalingInitialized; private const int ICON_DIMENSION = 16; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.AnchorUI.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.AnchorUI.cs index 7d64a0fd730..480d07a69a2 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.AnchorUI.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/AnchorEditor.AnchorUI.cs @@ -16,8 +16,8 @@ public sealed partial class AnchorEditor private class AnchorUI : Control { private readonly SpringControl bottom; - private readonly ContainerPlaceholder container = new ContainerPlaceholder(); - private readonly ControlPlaceholder control = new ControlPlaceholder(); + private readonly ContainerPlaceholder container = new(); + private readonly ControlPlaceholder control = new(); private readonly SpringControl left; private readonly SpringControl right; private readonly SpringControl[] tabOrder; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs index e617573ac4d..3aa09ca54d3 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.cs @@ -17,7 +17,7 @@ private partial class AdornerWindow : Control { private readonly BehaviorService _behaviorService; private static MouseHook? s_mouseHook; - private static readonly List s_adornerWindowList = new List(); + private static readonly List s_adornerWindowList = new(); /// /// Constructor that parents itself to the Designer Frame and hooks all @@ -318,19 +318,12 @@ protected override unsafe void WndProc(ref Message m) case PInvoke.WM_NCHITTEST: Point pt = PARAM.ToPoint(m.LParamInternal); - - var pt1 = default(Point); - pt1 = PointToClient(pt1); + Point pt1 = PointToClient(default); pt.Offset(pt1.X, pt1.Y); - if (_behaviorService.PropagateHitTest(pt) && !ProcessingDrag) - { - m.ResultInternal = (LRESULT)PInvoke.HTTRANSPARENT; - } - else - { - m.ResultInternal = (LRESULT)(int)PInvoke.HTCLIENT; - } + m.ResultInternal = _behaviorService.PropagateHitTest(pt) && !ProcessingDrag + ? (LRESULT)PInvoke.HTTRANSPARENT + : (LRESULT)(int)PInvoke.HTCLIENT; break; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.MenuCommandHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.MenuCommandHandler.cs index cb99418e97b..e45fe491e58 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.MenuCommandHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.MenuCommandHandler.cs @@ -11,7 +11,7 @@ public sealed partial class BehaviorService private class MenuCommandHandler : IMenuCommandService { private readonly BehaviorService _owner; - private readonly Stack _currentCommands = new Stack(); + private readonly Stack _currentCommands = new(); public MenuCommandHandler(BehaviorService owner, IMenuCommandService menuService) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs index 55b7ae1fc32..a2b8c9a1319 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.cs @@ -48,7 +48,7 @@ public sealed partial class BehaviorService : IDisposable private bool _queriedSnapLines; // only query for this once since we require the user restart design sessions when this changes private readonly HashSet _dragEnterReplies; // we keep track of whether glyph has already responded to a DragEnter this D&D. private static readonly TraceSwitch s_dragDropSwitch - = new TraceSwitch("BSDRAGDROP", "Behavior service drag & drop messages"); + = new("BSDRAGDROP", "Behavior service drag & drop messages"); //test hooks for SnapLines private static MessageId WM_GETALLSNAPLINES; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs index f4a709a376d..6b5f2fc9ce9 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DesignerActionKeyboardBehavior.cs @@ -13,7 +13,7 @@ internal sealed class DesignerActionKeyboardBehavior : Behavior private readonly DesignerActionPanel _panel; private readonly IMenuCommandService _menuService; private readonly DesignerActionUIService _daUISvc; - private static readonly Guid s_vSStandardCommandSet97 = new Guid("{5efc7975-14bc-11cf-9b2b-00aa00573819}"); + private static readonly Guid s_vSStandardCommandSet97 = new("{5efc7975-14bc-11cf-9b2b-00aa00573819}"); public DesignerActionKeyboardBehavior(DesignerActionPanel panel, IServiceProvider serviceProvider, BehaviorService behaviorService) : base(true, behaviorService) { diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs index b787226f9a9..3b7f927beec 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/DragAssistanceManager.cs @@ -24,7 +24,7 @@ internal sealed class DragAssistanceManager private Rectangle _cachedDragRect; //used to store drag rect between erasing & waiting to render private readonly Pen _edgePen = SystemPens.Highlight; private readonly bool _disposeEdgePen; - private readonly Pen _baselinePen = new Pen(Color.Fuchsia); + private readonly Pen _baselinePen = new(Color.Fuchsia); // These are global lists of all the existing vertical and horizontal snaplineson the designer's surface excluding the targetControl. All SnapLine coords in these lists have been properly adjusted for the AdornerWindow coords. private readonly List _verticalSnapLines = new(); private readonly List _horizontalSnapLines = new(); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs index d8a617439f4..977bb24561f 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ComponentTray.cs @@ -26,7 +26,7 @@ namespace System.Windows.Forms.Design; [ProvideProperty("TrayLocation", typeof(IComponent))] public class ComponentTray : ScrollableControl, IExtenderProvider, ISelectionUIHandler, IOleDragClient { - private static readonly Point InvalidPoint = new Point(int.MinValue, int.MinValue); + private static readonly Point InvalidPoint = new(int.MinValue, int.MinValue); private IServiceProvider serviceProvider; // Where services come from. private Point whiteSpace = Point.Empty; // space to leave between components. private Size grabHandle = Size.Empty; // Size of the grab handles. @@ -978,7 +978,7 @@ public Point GetTrayLocation(IComponent receiver) if (c is null) { Debug.Fail("Anything we're extending should have a component view."); - return default(Point); + return default; } Point loc = c.Location; @@ -2527,12 +2527,13 @@ protected override void WndProc(ref Message m) case PInvoke.WM_NCHITTEST: if (_tray.glyphManager is not null) { - // Make sure tha we send our glyphs hit test messages over the TrayControls too + // Make sure that we send our glyphs hit test messages over the TrayControls too. Point pt = PARAM.ToPoint(m.LParamInternal); - var pt1 = default(Point); - pt1 = PointToClient(pt1); + Point pt1 = PointToClient(default); pt.Offset(pt1.X, pt1.Y); - pt.Offset(Location.X, Location.Y); //offset the loc of the traycontrol -so now we're in comptray coords + + // Offset the location of the traycontrol so we're in component tray coordinates. + pt.Offset(Location.X, Location.Y); _tray.glyphManager.GetHitTest(pt); } @@ -2781,7 +2782,7 @@ private class TraySelectionUIHandler : SelectionUIHandler public TraySelectionUIHandler(ComponentTray tray) { _tray = tray; - _snapSize = default(Size); + _snapSize = default; } /// diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs index a8b78f0bd0c..98fe8eb7ecd 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ControlDesigner.cs @@ -309,7 +309,7 @@ public virtual SelectionRules SelectionRules internal Point GetOffsetToClientArea() { - var nativeOffset = default(Point); + Point nativeOffset = default; PInvoke.MapWindowPoints(Control, Control.Parent, ref nativeOffset); Point offset = Control.Location; @@ -319,7 +319,7 @@ internal Point GetOffsetToClientArea() offset.Offset(Control.Width, 0); } - return (new Point(Math.Abs(nativeOffset.X - offset.X), nativeOffset.Y - offset.Y)); + return new Point(Math.Abs(nativeOffset.X - offset.X), nativeOffset.Y - offset.Y); } /// @@ -2067,7 +2067,7 @@ protected virtual unsafe void WndProc(ref Message m) // First, save off the update region and call our base class. - RECT clip = default(RECT); + RECT clip = default; using var hrgn = new PInvoke.RegionScope(0, 0, 0, 0); PInvoke.GetUpdateRgn(m.HWND, hrgn, false); PInvoke.GetUpdateRect(m.HWND, &clip, false); diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs index 614e3f159a8..0b39a2f126b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerOptions.cs @@ -14,7 +14,7 @@ public class DesignerOptions { private const int MinGridSize = 2; private const int MaxGridSize = 200; - private Size _gridSize = new Size(8, 8); + private Size _gridSize = new(8, 8); /// /// Public GridSize property. diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs index e9be9d373c5..7fd04197b01 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerToolStripControlHost.cs @@ -28,7 +28,7 @@ public DesignerToolStripControlHost(Control c) : base(c) /// protected override Size DefaultSize { - get => new Size(92, 22); + get => new(92, 22); } internal GlyphCollection GetGlyphs(ToolStrip parent, GlyphCollection glyphs, Behavior.Behavior standardBehavior) diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs index b45fa1005d2..d620ab2e017 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DocumentDesigner.cs @@ -54,10 +54,10 @@ public partial class DocumentDesigner : ScrollableControlDesigner, IRootDesigner // ActiveX support // - private static readonly Guid htmlDesignTime = new Guid("73CEF3DD-AE85-11CF-A406-00AA00C00940"); + private static readonly Guid htmlDesignTime = new("73CEF3DD-AE85-11CF-A406-00AA00C00940"); private Dictionary axTools; - private static readonly TraceSwitch AxToolSwitch = new TraceSwitch("AxTool", "ActiveX Toolbox Tracing"); + private static readonly TraceSwitch AxToolSwitch = new("AxTool", "ActiveX Toolbox Tracing"); private const string AxClipFormat = "CLSID"; private ToolboxItemCreatorCallback toolboxCreator; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EventHandlerService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EventHandlerService.cs index f702083ced1..4f6ec5c8744 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EventHandlerService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/EventHandlerService.cs @@ -16,7 +16,7 @@ public sealed class EventHandlerService : IEventHandlerService private Type _lastHandlerType; private EventHandler _changedEvent; - private readonly LinkedList _handlers = new LinkedList(); + private readonly LinkedList _handlers = new(); /// /// Initializes a new instance of the EventHandlerService class. diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs index 550fc562ca8..510f00c067a 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FormatControl.cs @@ -17,7 +17,7 @@ internal partial class FormatControl : UserControl private const int ScientificIndex = 4; private const int CustomIndex = 5; - private TextBox customStringTextBox = new TextBox(); + private TextBox customStringTextBox = new(); // static because we want this value to be the same across a // VS session diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ItemTypeToolStripMenuItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ItemTypeToolStripMenuItem.cs index 108c7415b2c..ddccdee2547 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ItemTypeToolStripMenuItem.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ItemTypeToolStripMenuItem.cs @@ -15,7 +15,7 @@ namespace System.Windows.Forms.Design; internal class ItemTypeToolStripMenuItem : ToolStripMenuItem { private static readonly string s_systemWindowsFormsNamespace = typeof(ToolStripItem).Namespace; - private static readonly ToolboxItem s_invalidToolboxItem = new ToolboxItem(); + private static readonly ToolboxItem s_invalidToolboxItem = new(); private readonly Type _itemType; private bool _convertTo; private ToolboxItem _tbxItem = s_invalidToolboxItem; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs index 1216d69ba87..ffb9055d284 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MaskDesignerDialog.cs @@ -31,7 +31,7 @@ internal class MaskDesignerDialog : Form private Button _btnCancel; private ErrorProvider _errorProvider; - private readonly List _maskDescriptors = new List(); + private readonly List _maskDescriptors = new(); private MaskDescriptor _customMaskDescriptor; private SortOrder _listViewSortOrder = SortOrder.Ascending; private IContainer _components; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MenuCommands.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MenuCommands.cs index 326d1b59050..7750bd1aec2 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MenuCommands.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MenuCommands.cs @@ -64,94 +64,94 @@ public sealed class MenuCommands : StandardCommands /// This new guid is added so that the ToolStripDesigner now respond to the F2 command /// and go into InSitu Edit mode. /// - private static readonly Guid VSStandardCommandSet97 = new Guid("{5efc7975-14bc-11cf-9b2b-00aa00573819}"); + private static readonly Guid VSStandardCommandSet97 = new("{5efc7975-14bc-11cf-9b2b-00aa00573819}"); /// /// This guid corresponds to the menu grouping Windows Forms will use for its menus. This is /// defined in the Windows Forms menu CTC file, but we need it here so we can define what /// context menus to use. /// - private static readonly Guid wfMenuGroup = new Guid("{74D21312-2AEE-11d1-8BFB-00A0C90F26F7}"); + private static readonly Guid wfMenuGroup = new("{74D21312-2AEE-11d1-8BFB-00A0C90F26F7}"); /// /// This guid corresponds to the Windows Forms command set. /// - private static readonly Guid wfCommandSet = new Guid("{74D21313-2AEE-11d1-8BFB-00A0C90F26F7}"); + private static readonly Guid wfCommandSet = new("{74D21313-2AEE-11d1-8BFB-00A0C90F26F7}"); /// /// This guid is the standard vs 2k commands for key bindings /// - private static readonly Guid guidVSStd2K = new Guid("{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}"); + private static readonly Guid guidVSStd2K = new("{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}"); - public static readonly CommandID SelectionMenu = new CommandID(wfMenuGroup, mnuidSelection); + public static readonly CommandID SelectionMenu = new(wfMenuGroup, mnuidSelection); - public static readonly CommandID ContainerMenu = new CommandID(wfMenuGroup, mnuidContainer); + public static readonly CommandID ContainerMenu = new(wfMenuGroup, mnuidContainer); - public static readonly CommandID TraySelectionMenu = new CommandID(wfMenuGroup, mnuidTraySelection); + public static readonly CommandID TraySelectionMenu = new(wfMenuGroup, mnuidTraySelection); - public static readonly CommandID ComponentTrayMenu = new CommandID(wfMenuGroup, mnuidComponentTray); + public static readonly CommandID ComponentTrayMenu = new(wfMenuGroup, mnuidComponentTray); // Windows Forms commands - public static readonly CommandID DesignerProperties = new CommandID(wfCommandSet, cmdidDesignerProperties); + public static readonly CommandID DesignerProperties = new(wfCommandSet, cmdidDesignerProperties); // Windows Forms Key commands - public static readonly CommandID KeyCancel = new CommandID(guidVSStd2K, ECMD_CANCEL); + public static readonly CommandID KeyCancel = new(guidVSStd2K, ECMD_CANCEL); - public static readonly CommandID KeyReverseCancel = new CommandID(wfCommandSet, cmdidReverseCancel); + public static readonly CommandID KeyReverseCancel = new(wfCommandSet, cmdidReverseCancel); - public static readonly CommandID KeyInvokeSmartTag = new CommandID(guidVSStd2K, ECMD_INVOKESMARTTAG); + public static readonly CommandID KeyInvokeSmartTag = new(guidVSStd2K, ECMD_INVOKESMARTTAG); - public static readonly CommandID KeyDefaultAction = new CommandID(guidVSStd2K, ECMD_RETURN); + public static readonly CommandID KeyDefaultAction = new(guidVSStd2K, ECMD_RETURN); - public static readonly CommandID KeyMoveUp = new CommandID(guidVSStd2K, ECMD_UP); + public static readonly CommandID KeyMoveUp = new(guidVSStd2K, ECMD_UP); - public static readonly CommandID KeyMoveDown = new CommandID(guidVSStd2K, ECMD_DOWN); + public static readonly CommandID KeyMoveDown = new(guidVSStd2K, ECMD_DOWN); - public static readonly CommandID KeyMoveLeft = new CommandID(guidVSStd2K, ECMD_LEFT); + public static readonly CommandID KeyMoveLeft = new(guidVSStd2K, ECMD_LEFT); - public static readonly CommandID KeyMoveRight = new CommandID(guidVSStd2K, ECMD_RIGHT); + public static readonly CommandID KeyMoveRight = new(guidVSStd2K, ECMD_RIGHT); - public static readonly CommandID KeyNudgeUp = new CommandID(guidVSStd2K, ECMD_CTLMOVEUP); + public static readonly CommandID KeyNudgeUp = new(guidVSStd2K, ECMD_CTLMOVEUP); - public static readonly CommandID KeyNudgeDown = new CommandID(guidVSStd2K, ECMD_CTLMOVEDOWN); + public static readonly CommandID KeyNudgeDown = new(guidVSStd2K, ECMD_CTLMOVEDOWN); - public static readonly CommandID KeyNudgeLeft = new CommandID(guidVSStd2K, ECMD_CTLMOVELEFT); + public static readonly CommandID KeyNudgeLeft = new(guidVSStd2K, ECMD_CTLMOVELEFT); - public static readonly CommandID KeyNudgeRight = new CommandID(guidVSStd2K, ECMD_CTLMOVERIGHT); + public static readonly CommandID KeyNudgeRight = new(guidVSStd2K, ECMD_CTLMOVERIGHT); - public static readonly CommandID KeySizeWidthIncrease = new CommandID(guidVSStd2K, ECMD_RIGHT_EXT); + public static readonly CommandID KeySizeWidthIncrease = new(guidVSStd2K, ECMD_RIGHT_EXT); - public static readonly CommandID KeySizeHeightIncrease = new CommandID(guidVSStd2K, ECMD_UP_EXT); + public static readonly CommandID KeySizeHeightIncrease = new(guidVSStd2K, ECMD_UP_EXT); - public static readonly CommandID KeySizeWidthDecrease = new CommandID(guidVSStd2K, ECMD_LEFT_EXT); + public static readonly CommandID KeySizeWidthDecrease = new(guidVSStd2K, ECMD_LEFT_EXT); - public static readonly CommandID KeySizeHeightDecrease = new CommandID(guidVSStd2K, ECMD_DOWN_EXT); + public static readonly CommandID KeySizeHeightDecrease = new(guidVSStd2K, ECMD_DOWN_EXT); - public static readonly CommandID KeyNudgeWidthIncrease = new CommandID(guidVSStd2K, ECMD_CTLSIZERIGHT); + public static readonly CommandID KeyNudgeWidthIncrease = new(guidVSStd2K, ECMD_CTLSIZERIGHT); - public static readonly CommandID KeyNudgeHeightIncrease = new CommandID(guidVSStd2K, ECMD_CTLSIZEDOWN); + public static readonly CommandID KeyNudgeHeightIncrease = new(guidVSStd2K, ECMD_CTLSIZEDOWN); - public static readonly CommandID KeyNudgeWidthDecrease = new CommandID(guidVSStd2K, ECMD_CTLSIZELEFT); + public static readonly CommandID KeyNudgeWidthDecrease = new(guidVSStd2K, ECMD_CTLSIZELEFT); - public static readonly CommandID KeyNudgeHeightDecrease = new CommandID(guidVSStd2K, ECMD_CTLSIZEUP); + public static readonly CommandID KeyNudgeHeightDecrease = new(guidVSStd2K, ECMD_CTLSIZEUP); - public static readonly CommandID KeySelectNext = new CommandID(guidVSStd2K, ECMD_TAB); + public static readonly CommandID KeySelectNext = new(guidVSStd2K, ECMD_TAB); - public static readonly CommandID KeySelectPrevious = new CommandID(guidVSStd2K, ECMD_BACKTAB); + public static readonly CommandID KeySelectPrevious = new(guidVSStd2K, ECMD_BACKTAB); - public static readonly CommandID KeyTabOrderSelect = new CommandID(wfCommandSet, cmdidSpace); + public static readonly CommandID KeyTabOrderSelect = new(wfCommandSet, cmdidSpace); - public static readonly CommandID EditLabel = new CommandID(VSStandardCommandSet97, cmdidEditLabel); + public static readonly CommandID EditLabel = new(VSStandardCommandSet97, cmdidEditLabel); - public static readonly CommandID KeyHome = new CommandID(guidVSStd2K, ECMD_HOME); + public static readonly CommandID KeyHome = new(guidVSStd2K, ECMD_HOME); - public static readonly CommandID KeyEnd = new CommandID(guidVSStd2K, ECMD_END); + public static readonly CommandID KeyEnd = new(guidVSStd2K, ECMD_END); - public static readonly CommandID KeyShiftHome = new CommandID(guidVSStd2K, ECMD_HOME_EXT); + public static readonly CommandID KeyShiftHome = new(guidVSStd2K, ECMD_HOME_EXT); - public static readonly CommandID KeyShiftEnd = new CommandID(guidVSStd2K, ECMD_END_EXT); + public static readonly CommandID KeyShiftEnd = new(guidVSStd2K, ECMD_END_EXT); - public static readonly CommandID SetStatusText = new CommandID(wfCommandSet, cmdidSetStatusText); + public static readonly CommandID SetStatusText = new(wfCommandSet, cmdidSetStatusText); - public static readonly CommandID SetStatusRectangle = new CommandID(wfCommandSet, cmdidSetStatusRectangle); + public static readonly CommandID SetStatusRectangle = new(wfCommandSet, cmdidSetStatusRectangle); } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs index 1f96433dfdc..1aef91bbc58 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/OleDragDropHandler.cs @@ -871,7 +871,7 @@ public void DoOleDragDrop(DragEventArgs de) if (loc is not null && !loc.IsReadOnly) { - Rectangle bounds = default(Rectangle); + Rectangle bounds = default; Point pt = (Point)loc.GetValue(comp); bounds.X = dropPt.X + pt.X; bounds.Y = dropPt.Y + pt.Y; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs index 6623765ab72..12eae8a014b 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ParentControlDesigner.cs @@ -526,7 +526,7 @@ internal void AddControl(Control newChild, IDictionary defaultValues) if (host is not null && newChild is not null && !Control.Contains(newChild) && (host.GetDesigner(newChild) as ControlDesigner) is not null && !(newChild is Form && ((Form)newChild).TopLevel)) { - Rectangle bounds = default(Rectangle); + Rectangle bounds = default; // If we were provided with a location, convert it to parent control coordinates. // Otherwise, get the control's size and put the location in the middle of it diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs index 6d49041494b..8ac04c78cfb 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIHandler.cs @@ -39,7 +39,7 @@ internal abstract class SelectionUIHandler /// public virtual bool BeginDrag(object[] components, SelectionRules rules, int initialX, int initialY) { - dragOffset = default(Rectangle); + dragOffset = default; originalCoords = null; this.rules = rules; @@ -93,7 +93,7 @@ private static void CancelControlMove(Control[] controls, BoundsInfo[] bounds) { Debug.Assert(bounds is not null && controls is not null && bounds.Length == controls.Length, "bounds->controls mismatch"); - Rectangle b = default(Rectangle); + Rectangle b = default; // Whip through each of the controls. // @@ -209,7 +209,7 @@ private void MoveControls(object[] components, bool cancel, bool finalMove) Control[] controls = dragControls; Rectangle offset = dragOffset; BoundsInfo[] bounds = originalCoords; - Point adjustedLoc = default(Point); + Point adjustedLoc = default; // Erase the clipping and other state if this is the final move. // diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs index 8986b203675..019cd68a866 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.cs @@ -17,7 +17,7 @@ namespace System.Windows.Forms.Design; /// internal sealed partial class SelectionUIService : Control, ISelectionUIService { - private static readonly Point s_invalidPoint = new Point(int.MinValue, int.MinValue); + private static readonly Point s_invalidPoint = new(int.MinValue, int.MinValue); private const int HITTEST_CONTAINER_SELECTOR = 0x0001; private const int HITTEST_NORMAL_SELECTION = 0x0002; private const int HITTEST_DEFAULT = HITTEST_CONTAINER_SELECTOR | HITTEST_NORMAL_SELECTION; @@ -106,7 +106,7 @@ private void BeginMouseDrag(Point anchor, int hitTest) _mouseDragAnchor = anchor; _mouseDragging = true; _mouseDragHitTest = hitTest; - _mouseDragOffset = default(Rectangle); + _mouseDragOffset = default; _savedVisible = Visible; } diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.OrientationActionList.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.OrientationActionList.cs index 0b1ba275c7b..4bda93cbc4c 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.OrientationActionList.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.OrientationActionList.cs @@ -58,7 +58,7 @@ private void OnOrientationActionClick(object? sender, EventArgs e) actionUIService.Refresh(_ownerComponent); } - public override DesignerActionItemCollection GetSortedActionItems() => new DesignerActionItemCollection + public override DesignerActionItemCollection GetSortedActionItems() => new() { new DesignerActionVerbItem(new DesignerVerb(_actionName!, OnOrientationActionClick)) }; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.cs index d981202bc3b..4fea1ee4977 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SplitContainerDesigner.cs @@ -37,7 +37,7 @@ internal partial class SplitContainerDesigner : ParentControlDesigner /// /// Gets the design-time supported actions on the control. /// - public override DesignerActionListCollection ActionLists => new DesignerActionListCollection() + public override DesignerActionListCollection ActionLists => new() { new OrientationActionList(this) }; diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs index f209d7fb5b2..f2738e88be8 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/ToolStripDesigner.cs @@ -93,7 +93,7 @@ private Rectangle AddItemRect { get { - Rectangle rect = default(Rectangle); + Rectangle rect = default; if (_miniToolStrip is null) { return rect; @@ -372,7 +372,7 @@ private Rectangle OverFlowButtonRect { get { - Rectangle rect = default(Rectangle); + Rectangle rect = default; if (ToolStrip.OverflowButton.Visible) { return ToolStrip.OverflowButton.Bounds; diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerHostTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerHostTests.cs index eb5bf62537f..dcebab498b6 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerHostTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/DesignerHostTests.cs @@ -1727,7 +1727,7 @@ public void DesignerHost_AddService_InvokeObject_GetServiceReturnsExpected() SubDesignSurface surface = new(); IDesignerLoaderHost2 host = surface.Host; - object service = new object(); + object service = new(); host.AddService(typeof(object), service); Assert.Same(service, surface.ServiceContainer.GetService(typeof(object))); Assert.Same(service, surface.GetService(typeof(object))); @@ -1741,7 +1741,7 @@ public void DesignerHost_AddService_InvokeObjectBool_GetServiceReturnsExpected(b SubDesignSurface surface = new(); IDesignerLoaderHost2 host = surface.Host; - object service = new object(); + object service = new(); host.AddService(typeof(object), service, promote); Assert.Same(service, surface.ServiceContainer.GetService(typeof(object))); Assert.Same(service, surface.GetService(typeof(object))); @@ -1754,7 +1754,7 @@ public void DesignerHost_AddService_InvokeCallback_GetServiceReturnsExpected() SubDesignSurface surface = new(); IDesignerLoaderHost2 host = surface.Host; - object service = new object(); + object service = new(); ServiceCreatorCallback callback = (container, serviceType) => service; host.AddService(typeof(object), callback); Assert.Same(service, surface.ServiceContainer.GetService(typeof(object))); @@ -1769,7 +1769,7 @@ public void DesignerHost_AddService_InvokeObjectCallback_GetServiceReturnsExpect SubDesignSurface surface = new(); IDesignerLoaderHost2 host = surface.Host; - object service = new object(); + object service = new(); ServiceCreatorCallback callback = (container, serviceType) => service; host.AddService(typeof(object), callback, promote); Assert.Same(service, surface.ServiceContainer.GetService(typeof(object))); diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataMemberFieldConverterTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataMemberFieldConverterTests.cs index 6df25f049d4..d0bfc9c3b1b 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataMemberFieldConverterTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/DataMemberFieldConverterTests.cs @@ -10,7 +10,7 @@ namespace System.Windows.Forms.Design.Tests; public class DataMemberFieldConverterTests { - private static DataMemberFieldConverter s_converter = new DataMemberFieldConverter(); + private static DataMemberFieldConverter s_converter = new(); private static ITypeDescriptorContext s_context = new MyTypeDescriptorContext(); [Fact] diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Interop.ARGB.cs b/src/System.Windows.Forms.Primitives/src/Interop/Interop.ARGB.cs index 89402070e82..6bb6e5c7bb1 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Interop.ARGB.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Interop.ARGB.cs @@ -40,6 +40,6 @@ public unsafe ARGB(int value) Value = value; } - public static implicit operator ARGB(Color color) => new ARGB(color.ToArgb()); + public static implicit operator ARGB(Color color) => new(color.ToArgb()); public static implicit operator Color(ARGB argb) => Color.FromArgb(argb.Value); } diff --git a/src/System.Windows.Forms.Primitives/src/Interop/Interop.POINTS.cs b/src/System.Windows.Forms.Primitives/src/Interop/Interop.POINTS.cs index ce7eef15f4e..04448be11f3 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/Interop.POINTS.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/Interop.POINTS.cs @@ -13,6 +13,6 @@ public struct POINTS public override string ToString() => $"{{X={x} Y={y}}}"; - public static implicit operator Point(POINTS point) => new Point(point.x, point.y); + public static implicit operator Point(POINTS point) => new(point.x, point.y); } } diff --git a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANT.cs b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANT.cs index 62a59e433e7..9107c36e92e 100644 --- a/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANT.cs +++ b/src/System.Windows.Forms.Primitives/src/Interop/OleAut32/Interop.VARIANT.cs @@ -940,7 +940,7 @@ public static explicit operator CY(VARIANT value) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static explicit operator VARIANT(IUnknown* value) - => new VARIANT() + => new() { vt = VT_UNKNOWN, data = new() { punkVal = value } diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/ICategorizeProperties.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/ICategorizeProperties.cs index 290d870a875..cbd15e67cb9 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/ICategorizeProperties.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/ICategorizeProperties.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.Shell; /// internal unsafe struct ICategorizeProperties : IComIID { - internal static readonly Guid Guid = new Guid(0x4D07FC10, 0xF931, 0x11CE, 0xB0, 0x01, 0x00, 0xAA, 0x00, 0x68, 0x84, 0xE5); + internal static readonly Guid Guid = new(0x4D07FC10, 0xF931, 0x11CE, 0xB0, 0x01, 0x00, 0xAA, 0x00, 0x68, 0x84, 0xE5); static ref readonly Guid IComIID.Guid { diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IProvidePropertyBuilder.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IProvidePropertyBuilder.cs index bef88a767c3..2309c93e723 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IProvidePropertyBuilder.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IProvidePropertyBuilder.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.Shell; internal unsafe struct IProvidePropertyBuilder : IComIID { - internal static readonly Guid Guid = new Guid(0x33C0C1D8, 0x33CF, 0x11d3, 0xBF, 0xF2, 0x00, 0xC0, 0x4F, 0x99, 0x02, 0x35); + internal static readonly Guid Guid = new(0x33C0C1D8, 0x33CF, 0x11d3, 0xBF, 0xF2, 0x00, 0xC0, 0x4F, 0x99, 0x02, 0x35); static ref readonly Guid IComIID.Guid { diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVSMDPerPropertyBrowsing.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVSMDPerPropertyBrowsing.cs index 378655f9b26..218e46cfa68 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVSMDPerPropertyBrowsing.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVSMDPerPropertyBrowsing.cs @@ -12,7 +12,7 @@ namespace Microsoft.VisualStudio.Shell; /// internal unsafe struct IVSMDPerPropertyBrowsing : IComIID { - internal static readonly Guid Guid = new Guid(0x7494683C, 0x37A0, 0x11D2, 0xA2, 0x73, 0x00, 0xC0, 0x4F, 0x8E, 0xF4, 0xFF); + internal static readonly Guid Guid = new(0x7494683C, 0x37A0, 0x11D2, 0xA2, 0x73, 0x00, 0xC0, 0x4F, 0x8E, 0xF4, 0xFF); static ref readonly Guid IComIID.Guid { diff --git a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVsPerPropertyBrowsing.cs b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVsPerPropertyBrowsing.cs index b581f860213..a2f0e55e81a 100644 --- a/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVsPerPropertyBrowsing.cs +++ b/src/System.Windows.Forms.Primitives/src/Microsoft/VisualStudio/Shell/IVsPerPropertyBrowsing.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.Shell; /// internal unsafe struct IVsPerPropertyBrowsing : IComIID { - public static readonly Guid Guid = new Guid(0x0FF510A3, 0x5FA5, 0x49F1, 0x8C, 0xCC, 0x19, 0x0D, 0x71, 0x08, 0x3F, 0x3E); + public static readonly Guid Guid = new(0x0FF510A3, 0x5FA5, 0x49F1, 0x8C, 0xCC, 0x19, 0x0D, 0x71, 0x08, 0x3F, 0x3E); static ref readonly Guid IComIID.Guid { diff --git a/src/System.Windows.Forms.Primitives/src/System/EasyPoint.cs b/src/System.Windows.Forms.Primitives/src/System/EasyPoint.cs index 836d22351c9..7b1058ce525 100644 --- a/src/System.Windows.Forms.Primitives/src/System/EasyPoint.cs +++ b/src/System.Windows.Forms.Primitives/src/System/EasyPoint.cs @@ -16,7 +16,7 @@ internal readonly struct EasyPoint public EasyPoint(int x, int y) => (X, Y) = (x, y); public EasyPoint((int X, int Y) point) => (X, Y) = point; public void Deconstruct(out int x, out int y) => (x, y) = (X, Y); - public static implicit operator Point(in EasyPoint point) => new Point(point.X, point.Y); - public static implicit operator EasyPoint(Point point) => new EasyPoint(point.X, point.Y); - public static implicit operator EasyPoint(in (int X, int Y) point) => new EasyPoint(point); + public static implicit operator Point(in EasyPoint point) => new(point.X, point.Y); + public static implicit operator EasyPoint(Point point) => new(point.X, point.Y); + public static implicit operator EasyPoint(in (int X, int Y) point) => new(point); } diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider.cs index 786d39dcf70..0558cd6de66 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Automation/UiaTextProvider.cs @@ -106,7 +106,7 @@ public int SendInput(int inputs, ref INPUT input, int size) public unsafe int SendKeyboardInputVK(VIRTUAL_KEY vk, bool press) { - INPUT keyboardInput = default(INPUT); + INPUT keyboardInput = default; keyboardInput.type = INPUT_TYPE.INPUT_KEYBOARD; keyboardInput.Anonymous.ki.wVk = vk; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextExtensions.cs index 0bd25003652..3c5c332904f 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/DeviceContextExtensions.cs @@ -89,7 +89,7 @@ internal static unsafe void DrawLines(this HDC hdc, HPEN hpen, ReadOnlySpan using PInvoke.SetBkModeScope bkScope = new(hdc, BACKGROUND_MODE.TRANSPARENT); using PInvoke.SelectObjectScope selection = new(hdc, (HGDIOBJ)hpen.Value); - Point oldPoint = default(Point); + Point oldPoint = default; for (int i = 0; i < lines.Length; i += 4) { diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnicodeCharBuffer.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnicodeCharBuffer.cs index 91fd53dbc17..d2bb36566d6 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnicodeCharBuffer.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/UnicodeCharBuffer.cs @@ -31,7 +31,7 @@ public string GetString() i++; } - string result = new string(_buffer, _offset, i - _offset); + string result = new(_buffer, _offset, i - _offset); if (i < _buffer.Length) { i++; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/WeakRefCollection.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/WeakRefCollection.cs index 9f2d360742e..055ce36c1c5 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/WeakRefCollection.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/WeakRefCollection.cs @@ -106,7 +106,7 @@ public override bool Equals(object? obj) public override int GetHashCode() { - var hash = default(HashCode); + HashCode hash = default; foreach (WeakRefObject? o in InnerList) { hash.Add(o); diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Padding.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Padding.cs index 8fd92856e1f..9ac569bfa03 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Padding.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Padding.cs @@ -18,7 +18,7 @@ public struct Padding : IEquatable private int _right; // Do NOT rename (binary serialization). private int _bottom; // Do NOT rename (binary serialization). - public static readonly Padding Empty = new Padding(0); + public static readonly Padding Empty = new(0); public Padding(int all) { @@ -124,7 +124,7 @@ public int Top public int Vertical => Top + Bottom; [Browsable(false)] - public Size Size => new Size(Horizontal, Vertical); + public Size Size => new(Horizontal, Vertical); public static Padding Add(Padding p1, Padding p2) => p1 + p2; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.cs index fdcbece8fa0..77a6a7125ad 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/RefCountedCache.cs @@ -22,7 +22,7 @@ namespace System.Windows.Forms; /// internal abstract partial class RefCountedCache : IDisposable { - private readonly SinglyLinkedList _list = new SinglyLinkedList(); + private readonly SinglyLinkedList _list = new(); private readonly int _softLimit; private readonly int _hardLimit; diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SinglyLinkedList.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SinglyLinkedList.cs index 8f7e9cfc7a6..d10ead70d06 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SinglyLinkedList.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SinglyLinkedList.cs @@ -55,7 +55,7 @@ public Node AddLast(T value) return node; } - public Enumerator GetEnumerator() => new Enumerator(this); + public Enumerator GetEnumerator() => new(this); public class Node { diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SystemDrawingExtensions.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SystemDrawingExtensions.cs index a5cd5270d9e..6302fde8bfc 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SystemDrawingExtensions.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/SystemDrawingExtensions.cs @@ -117,7 +117,7 @@ internal static Pen CreateStaticPen(this Color color, DashStyle dashStyle, float /// Not strictly needed (yet), but allows using the same pattern for all pens. /// internal static Pen CreateStaticPen(this Brush brush, float width = 1.0f) - => new Pen(brush, width); + => new(brush, width); /// /// Creates a . If is a system color, makes a static copy of diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/GetDcScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/GetDcScope.cs index 6853efac549..9194f3244e7 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/GetDcScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/GetDcScope.cs @@ -53,7 +53,7 @@ public GetDcScope(HWND hwnd, HRGN hrgnClip, GET_DCX_FLAGS flags) /// API to get the DC for the entire desktop. /// /// - public static GetDcScope ScreenDC => new GetDcScope(HWND.Null); + public static GetDcScope ScreenDC => new(HWND.Null); public bool IsNull => HDC.IsNull; diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCID.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCID.cs index 1b982e0f826..1a663d76899 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCID.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.LCID.cs @@ -30,8 +30,8 @@ public override bool Equals(object? obj) public static bool operator !=(LCID a, LCID b) => a.RawValue != b.RawValue; - public static implicit operator LCID(uint value) => new LCID(value); + public static implicit operator LCID(uint value) => new(value); - public static readonly LCID USER_DEFAULT = new LCID(0x0400); + public static readonly LCID USER_DEFAULT = new(0x0400); } } diff --git a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectPaletteScope.cs b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectPaletteScope.cs index f23d7cb40ae..47bacd3aa60 100644 --- a/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectPaletteScope.cs +++ b/src/System.Windows.Forms.Primitives/src/Windows/Win32/PInvoke.SelectPaletteScope.cs @@ -48,7 +48,7 @@ public static SelectPaletteScope HalftonePalette(HDC hdc, bool forceBackground, #if DEBUG return new SelectPaletteScope(); #else - return default(SelectPaletteScope); + return default; #endif } diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/DeviceContextState.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/DeviceContextState.cs index 4a16a6fa5b4..8ef9baf36a1 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/DeviceContextState.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/DeviceContextState.cs @@ -18,7 +18,7 @@ internal unsafe class DeviceContextState // Not all state is handled yet. Backfilling in as we write specific tests. Of special note is that we don't // have tracking for Save/RestoreDC yet. - private readonly List _savedStates = new List(); + private readonly List _savedStates = new(); private State _currentState; /// diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs index f330d8d293f..3f97980b5ff 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs @@ -55,7 +55,7 @@ private static unsafe HDC CreateEnhMetaFile( } } - public static unsafe EmfScope Create() => new EmfScope(); + public static unsafe EmfScope Create() => new(); public HENHMETAFILE HENHMETAFILE { diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs index 8d131fa342f..c6061ad2aae 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/NoAssertContext.cs @@ -21,16 +21,16 @@ public sealed class NoAssertContext : IDisposable // We do, however need to lock around hooking/unhooking our custom listener to make sure that we // are rerouting correctly if multiple threads are creating/disposing this class concurrently. - private static readonly object s_lock = new object(); + private static readonly object s_lock = new(); private static bool s_hooked; private static bool s_hasDefaultListener; private static bool s_hasThrowingListener; - private static readonly ConcurrentDictionary s_suppressedThreads = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary s_suppressedThreads = new(); // "Default" is the listener that terminates the process when debug assertions fail. private static readonly TraceListener? s_defaultListener = Trace.Listeners["Default"]; - private static readonly NoAssertListener s_noAssertListener = new NoAssertListener(); + private static readonly NoAssertListener s_noAssertListener = new(); public NoAssertContext() { diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs index 0477298a06c..a52fcc5683f 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.Windows.cs @@ -33,7 +33,7 @@ public static partial class PlatformDetection public static bool IsWindowsServerCore => GetInstallationType().Equals("Server Core", StringComparison.OrdinalIgnoreCase); public static int WindowsVersion => GetWindowsVersion(); public static bool IsMacOsHighSierraOrHigher { get; } - public static Version ICUVersion => new Version(0, 0, 0, 0); + public static Version ICUVersion => new(0, 0, 0, 0); public static bool IsRedHatFamily => false; public static bool IsNotRedHatFamily => true; public static bool IsRedHatFamily6 => false; diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.cs b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.cs index 30d0adf6283..158a7f9cb2e 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.cs +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities/PlatformDetection.cs @@ -65,7 +65,7 @@ public static partial class PlatformDetection // running in AppContainer when running on .NetNative. public static bool IsNotNetNativeRunningAsConsoleApp => !(IsNetNative && !IsInAppContainer); - private static readonly Lazy m_isWindowsSubsystemForLinux = new Lazy(GetIsWindowsSubsystemForLinux); + private static readonly Lazy m_isWindowsSubsystemForLinux = new(GetIsWindowsSubsystemForLinux); public static bool IsWindowsSubsystemForLinux => m_isWindowsSubsystemForLinux.Value; public static bool IsNotWindowsSubsystemForLinux => !IsWindowsSubsystemForLinux; @@ -91,7 +91,7 @@ private static bool GetIsWindowsSubsystemForLinux() return false; } - private static readonly Lazy s_largeArrayIsNotSupported = new Lazy(IsLargeArrayNotSupported); + private static readonly Lazy s_largeArrayIsNotSupported = new(IsLargeArrayNotSupported); [MethodImpl(MethodImplOptions.NoOptimization)] private static bool IsLargeArrayNotSupported() diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/GdiPlus/ARGBTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/GdiPlus/ARGBTests.cs index cd43fb6224e..7b4aa22b589 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/GdiPlus/ARGBTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/GdiPlus/ARGBTests.cs @@ -37,7 +37,7 @@ public void ToFromColor(Color color) } public static TheoryData Colors => - new TheoryData + new() { Color.CornflowerBlue, Color.Transparent, diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/CHARFORMAT2WTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/CHARFORMAT2WTests.cs index 83584d673ad..0b0af238ca4 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/CHARFORMAT2WTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Richedit/CHARFORMAT2WTests.cs @@ -28,7 +28,7 @@ public unsafe void CharFormat_FaceName() // CHARFORMAT has space for 32 characters, we want to see it gets // cut to 31 to make room for the null. - string bigString = new string('*', 32); + string bigString = new('*', 32); charFormat.FaceName = bigString; Assert.True(charFormat.FaceName.SequenceEqual(bigString.AsSpan().Slice(1))); diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/GetWindowTextTests.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/GetWindowTextTests.cs index 42b641cf96c..c6f95778591 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/GetWindowTextTests.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/User32/GetWindowTextTests.cs @@ -23,7 +23,7 @@ private void CallGetWindowText(bool useBeforeGetTextLengthCallback) const string shortText = "A"; // Use a long string that exceeds the initial buffer size (16). - string longText = new string('X', 50); + string longText = new('X', 50); var windowClass = new ChangeWindowTextClass(); windowClass.Register(); diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/TestAccessors.UiaTextRangeTestAccessor.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/TestAccessors.UiaTextRangeTestAccessor.cs index 604f3031e2d..bf374812630 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/TestAccessors.UiaTextRangeTestAccessor.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/Automation/TestAccessors.UiaTextRangeTestAccessor.cs @@ -65,5 +65,5 @@ public HorizontalTextAlignment GetHorizontalTextAlignment(WINDOW_STYLE windowSty } internal static UiaTextRangeTestAccessor TestAccessor(this UiaTextRange textRange) - => new UiaTextRangeTestAccessor(textRange); + => new(textRange); } diff --git a/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.cs b/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.cs index 97df975da13..44433d16a62 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXResourceReader.cs @@ -290,7 +290,7 @@ public static ResXResourceReader FromFileContents(string fileContents) /// Creates a reader with the specified file contents. /// public static ResXResourceReader FromFileContents(string fileContents, ITypeResolutionService? typeResolver) - => new ResXResourceReader(typeResolver) + => new(typeResolver) { _fileContents = fileContents }; @@ -299,7 +299,7 @@ public static ResXResourceReader FromFileContents(string fileContents, ITypeReso /// Creates a reader with the specified file contents. /// public static ResXResourceReader FromFileContents(string fileContents, AssemblyName[] assemblyNames) - => new ResXResourceReader(assemblyNames) + => new(assemblyNames) { _fileContents = fileContents }; diff --git a/src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs b/src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs index 5d83b43397a..fdc67ccee79 100644 --- a/src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs +++ b/src/System.Windows.Forms/src/System/Resources/ResXResourceWriter.cs @@ -31,7 +31,7 @@ public class ResXResourceWriter : IResourceWriter private Dictionary? _cachedAliases; - private static readonly TraceSwitch s_resValueProviderSwitch = new TraceSwitch("ResX", "Debug the resource value provider"); + private static readonly TraceSwitch s_resValueProviderSwitch = new("ResX", "Debug the resource value provider"); #pragma warning disable IDE1006 // Naming Styles (Shipped public API) public static readonly string BinSerializedObjectMimeType = "application/x-microsoft.net.object.binary.base64"; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoleControlTypeMap.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoleControlTypeMap.cs index 604ec8e45a3..30ded6f22a3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoleControlTypeMap.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AccessibleRoleControlTypeMap.cs @@ -11,7 +11,7 @@ namespace System.Windows.Forms; /// internal static class AccessibleRoleControlTypeMap { - private static readonly Dictionary s_map = new Dictionary + private static readonly Dictionary s_map = new() { { AccessibleRole.Alert, UIA.PaneControlTypeId }, { AccessibleRole.Animation, UIA.PaneControlTypeId }, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ArrangedElement.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ArrangedElement.cs index a57c69234ca..41c05316f05 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ArrangedElement.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ArrangedElement.cs @@ -14,7 +14,7 @@ internal abstract class ArrangedElement : Component, IArrangedElement private Rectangle _bounds = Rectangle.Empty; private IArrangedElement? _parent; private BitVector32 _state; - private readonly PropertyStore _propertyStore = new PropertyStore(); // Contains all properties that are not always set. + private readonly PropertyStore _propertyStore = new(); // Contains all properties that are not always set. private static readonly int s_stateVisible = BitVector32.CreateMask(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs index a21d498e5ee..c91d2d1368c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs @@ -2307,7 +2307,7 @@ private unsafe string GetLicenseKey(Guid clsid) return null; } - var licInfo = new LICINFO + LICINFO licInfo = new() { cbLicInfo = sizeof(LICINFO) }; @@ -3784,7 +3784,7 @@ private static FONTDESC GetFONTDESCFromFont(Font font) } LOGFONTW logfont = LOGFONTW.FromFont(font); - var fdesc = new FONTDESC + FONTDESC fdesc = new() { cbSizeofstruct = (uint)sizeof(FONTDESC), cySize = (CY)font.SizeInPoints, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs index 0b95628a1e5..98697493021 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs @@ -608,11 +608,11 @@ private object ParseObject(object value) if (_formattingEnabled) { // Fire the Parse event so that user code gets a chance to supply the parsed value for us - var e = new ConvertEventArgs(value, type); + ConvertEventArgs e = new(value, type); OnParse(e); object newValue = e.Value; - if (!object.Equals(value, newValue)) + if (!Equals(value, newValue)) { // If event handler replaced formatted value with parsed value, use that return newValue; @@ -626,27 +626,36 @@ private object ParseObject(object value) fieldInfoConverter = _bindToObject.FieldInfo.Converter; } - return Formatter.ParseObject(value, type, (value is null ? _propInfo.PropertyType : value.GetType()), fieldInfoConverter, _propInfoConverter, _formatInfo, _nullValue, GetDataSourceNullValue(type)); + return Formatter.ParseObject( + value, + type, + (value is null ? _propInfo.PropertyType : value.GetType()), + fieldInfoConverter, + _propInfoConverter, + _formatInfo, + _nullValue, + GetDataSourceNullValue(type)); } } else { - var e = new ConvertEventArgs(value, type); - // first try: use the OnParse event + ConvertEventArgs e = new(value, type); + + // First try: use the OnParse event OnParse(e); if (e.Value is not null && (e.Value.GetType().IsSubclassOf(type) || e.Value.GetType() == type || e.Value is DBNull)) { return e.Value; } - // second try: use the TypeConverter + // Second try: use the TypeConverter TypeConverter typeConverter = TypeDescriptor.GetConverter(value is not null ? value.GetType() : typeof(object)); if (typeConverter is not null && typeConverter.CanConvertTo(type)) { return typeConverter.ConvertTo(value, type); } - // last try: use Convert.ToType + // Last try: use Convert.ToType if (value is IConvertible) { object ret = Convert.ChangeType(value, type, CultureInfo.CurrentCulture); @@ -674,7 +683,7 @@ private object FormatObject(object value) if (_formattingEnabled) { // Fire the Format event so that user code gets a chance to supply the formatted value for us - var e = new ConvertEventArgs(value, type); + ConvertEventArgs e = new(value, type); OnFormat(e); if (e.Value != value) @@ -697,7 +706,7 @@ private object FormatObject(object value) else { // first try: use the Format event - var e = new ConvertEventArgs(value, type); + ConvertEventArgs e = new(value, type); OnFormat(e); object ret = e.Value; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingSource.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingSource.cs index eeafd8f7017..37cfcefe550 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingSource.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingSource.cs @@ -26,16 +26,16 @@ public class BindingSource : Component, ICurrencyManagerProvider { // Public events - private static readonly object s_eventAddingNew = new object(); - private static readonly object s_eventBindingComplete = new object(); - private static readonly object s_eventCurrentChanged = new object(); - private static readonly object s_eventCurrentItemChanged = new object(); - private static readonly object s_eventDataError = new object(); - private static readonly object s_eventDataMemberChanged = new object(); - private static readonly object s_eventDataSourceChanged = new object(); - private static readonly object s_eventListChanged = new object(); - private static readonly object s_eventPositionChanged = new object(); - private static readonly object s_eventInitialized = new object(); + private static readonly object s_eventAddingNew = new(); + private static readonly object s_eventBindingComplete = new(); + private static readonly object s_eventCurrentChanged = new(); + private static readonly object s_eventCurrentItemChanged = new(); + private static readonly object s_eventDataError = new(); + private static readonly object s_eventDataMemberChanged = new(); + private static readonly object s_eventDataSourceChanged = new(); + private static readonly object s_eventListChanged = new(); + private static readonly object s_eventPositionChanged = new(); + private static readonly object s_eventInitialized = new(); // Public property values private object _dataSource; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/BindingsCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/BindingsCollection.cs index d6fc1dbe789..e31e58ac031 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/BindingsCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/BindingsCollection.cs @@ -35,7 +35,7 @@ internal BindingsCollection() protected internal void Add(Binding binding) { - var eventArgs = new CollectionChangeEventArgs(CollectionChangeAction.Add, binding); + CollectionChangeEventArgs eventArgs = new(CollectionChangeAction.Add, binding); OnCollectionChanging(eventArgs); AddCore(binding); OnCollectionChanged(eventArgs); @@ -72,7 +72,7 @@ public event CollectionChangeEventHandler? CollectionChanged protected internal void Clear() { - var eventArgs = new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null); + CollectionChangeEventArgs eventArgs = new(CollectionChangeAction.Refresh, null); OnCollectionChanging(eventArgs); ClearCore(); OnCollectionChanged(eventArgs); @@ -101,7 +101,7 @@ protected virtual void OnCollectionChanged(CollectionChangeEventArgs ccevent) protected internal void Remove(Binding binding) { - var eventArgs = new CollectionChangeEventArgs(CollectionChangeAction.Remove, binding); + CollectionChangeEventArgs eventArgs = new(CollectionChangeAction.Remove, binding); OnCollectionChanging(eventArgs); RemoveCore(binding); OnCollectionChanged(eventArgs); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs index fae62a4bb37..7ea83a31d15 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs @@ -30,7 +30,7 @@ public partial class Button : ButtonBase, IButtonControl /// For buttons whose FlatStyle = FlatStyle.Flat, this property specifies the size, in pixels /// of the border around the button. /// - private Size _systemSize = new Size(InvalidDimensionValue, InvalidDimensionValue); + private Size _systemSize = new(InvalidDimensionValue, InvalidDimensionValue); /// /// Initializes a new instance of the diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs index 0ef98736b40..c7c3ca4dca5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs @@ -22,7 +22,7 @@ public abstract partial class ButtonBase : Control, ICommandBindingTargetProvide private ContentAlignment _imageAlign = ContentAlignment.MiddleCenter; private ContentAlignment _textAlign = ContentAlignment.MiddleCenter; private TextImageRelation _textImageRelation = TextImageRelation.Overlay; - private readonly ImageList.Indexer _imageIndex = new ImageList.Indexer(); + private readonly ImageList.Indexer _imageIndex = new(); private FlatButtonAppearance? _flatAppearance; private ImageList? _imageList; private Image? _image; @@ -254,7 +254,7 @@ public event EventHandler? CommandParameterChanged remove => Events.RemoveHandler(s_commandParameterChangedEvent, value); } - protected override Size DefaultSize => new Size(75, 23); + protected override Size DefaultSize => new(75, 23); protected override CreateParams CreateParams { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorOptions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorOptions.cs index 6e7fbbd328c..229d230b9ce 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorOptions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.ColorOptions.cs @@ -116,7 +116,7 @@ internal ColorData Calculate() colors.WindowText = colors.WindowFrame; } - using var hdc = new DeviceContextHdcScope(_deviceContext, applyGraphicsState: false); + using DeviceContextHdcScope hdc = new(_deviceContext, applyGraphicsState: false); colors.ButtonFace = hdc.FindNearestColor(colors.ButtonFace); colors.ButtonShadow = hdc.FindNearestColor(colors.ButtonShadow); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.cs index c79833e3354..95b8968eda5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.LayoutOptions.cs @@ -176,7 +176,7 @@ static int xDecompose(Composition composition, int checkSize, int imageSize, int private Composition GetHorizontalComposition() { - BitVector32 action = default(BitVector32); + BitVector32 action = default; // Checks reserve space horizontally if possible, so only AnyLeft/AnyRight prevents combination. action[s_combineCheck] = @@ -239,7 +239,7 @@ internal Size GetPreferredSizeCore(Size proposedSize) private Composition GetVerticalComposition() { - BitVector32 action = default(BitVector32); + BitVector32 action = default; // Checks reserve space horizontally if possible, so only Top/Bottom prevents combination. action[s_combineCheck] = CheckAlign == ContentAlignment.MiddleCenter || !LayoutUtils.IsVerticalAlignment(CheckAlign); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.cs index 194b9487cff..6e0446d8b3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonBaseAdapter.cs @@ -52,7 +52,7 @@ internal virtual Size GetPreferredSizeCore(Size proposedSize) { LayoutOptions? options = default; using (var screen = GdiCache.GetScreenHdc()) - using (PaintEventArgs pe = new PaintEventArgs(screen, default(Rectangle))) + using (PaintEventArgs pe = new PaintEventArgs(screen, default)) { options = Layout(pe); } @@ -138,7 +138,7 @@ private void Draw3DBorderHighContrastRaised(IDeviceContext deviceContext, ref Re bool stockColor = colors.ButtonFace.ToKnownColor() == SystemColors.Control.ToKnownColor(); bool disabledHighContrast = (!Control.Enabled) && SystemInformation.HighContrast; - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); // Draw counter-clock-wise Point p1 = new Point(bounds.X + bounds.Width - 1, bounds.Y); // Upper inner right @@ -193,7 +193,7 @@ private void Draw3DBorderHighContrastRaised(IDeviceContext deviceContext, ref Re private static void Draw3DBorderNormal(IDeviceContext deviceContext, ref Rectangle bounds, ColorData colors) { - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); // Draw counter-clock-wise Point p1 = new Point(bounds.X + bounds.Width - 1, bounds.Y); // Upper inner right @@ -241,7 +241,7 @@ private void Draw3DBorderRaised(IDeviceContext deviceContext, ref Rectangle boun bool stockColor = colors.ButtonFace.ToKnownColor() == SystemColors.Control.ToKnownColor(); bool disabledHighContrast = (!Control.Enabled) && SystemInformation.HighContrast; - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); // Draw counter-clock-wise. Point p1 = new Point(bounds.X + bounds.Width - 1, bounds.Y); // Upper inner right @@ -300,13 +300,13 @@ private void Draw3DBorderRaised(IDeviceContext deviceContext, ref Rectangle boun /// protected internal static void Draw3DLiteBorder(IDeviceContext deviceContext, Rectangle r, ColorData colors, bool up) { - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); // Draw counter-clock-wise. - Point p1 = new Point(r.Right - 1, r.Top); // Upper inner right - Point p2 = new Point(r.Left, r.Top); // Upper left - Point p3 = new Point(r.Left, r.Bottom - 1); // Bottom inner left - Point p4 = new Point(r.Right - 1, r.Bottom - 1); // Inner bottom right + Point p1 = new(r.Right - 1, r.Top); // Upper inner right + Point p2 = new(r.Left, r.Top); // Upper left + Point p3 = new(r.Left, r.Bottom - 1); // Bottom inner left + Point p4 = new(r.Right - 1, r.Bottom - 1); // Inner bottom right Color color = GetContrastingBorderColor(colors.ButtonShadow); // Top, left @@ -326,21 +326,20 @@ protected internal static void Draw3DLiteBorder(IDeviceContext deviceContext, Re /// /// Draws the flat border with specified bordersize. /// - /// - /// This function gets called only for Flatstyle == Flatstyle.Flat. - /// internal static void DrawFlatBorderWithSize( PaintEventArgs e, Rectangle bounds, Color color, int size) { + // This function gets called only for Flatstyle == Flatstyle.Flat. + size = Math.Min(size, Math.Min(bounds.Width, bounds.Height)); - var left = new Rectangle(bounds.X, bounds.Y, size, bounds.Height); - var right = new Rectangle(bounds.X + bounds.Width - size, bounds.Y, size, bounds.Height); - var top = new Rectangle(bounds.X + size, bounds.Y, bounds.Width - size * 2, size); - var bottom = new Rectangle(bounds.X + size, bounds.Y + bounds.Height - size, bounds.Width - size * 2, size); + Rectangle left = new(bounds.X, bounds.Y, size, bounds.Height); + Rectangle right = new(bounds.X + bounds.Width - size, bounds.Y, size, bounds.Height); + Rectangle top = new(bounds.X + size, bounds.Y, bounds.Width - size * 2, size); + Rectangle bottom = new(bounds.X + size, bounds.Y + bounds.Height - size, bounds.Width - size * 2, size); if (color.HasTransparency()) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonStandardAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonStandardAdapter.cs index e48c3ddbb3a..73fe6d62a06 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonStandardAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/ButtonStandardAdapter.cs @@ -89,7 +89,7 @@ private void PaintThemedButtonBackground(PaintEventArgs e, Rectangle bounds, boo } else { - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); hdc.FillRectangle( bounds, isHighContrastHighlighted diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxBaseAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxBaseAdapter.cs index 95b021a1c7a..a54d7dfdbbc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxBaseAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxBaseAdapter.cs @@ -98,7 +98,7 @@ internal static void DrawCheckBackground( Color checkBackground, bool disabledColors) { - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); Color color; @@ -212,13 +212,13 @@ internal static void DrawCheckOnly( internal static Rectangle DrawPopupBorder(Graphics g, Rectangle r, ColorData colors) { - using var hdc = new DeviceContextHdcScope(g); + using DeviceContextHdcScope hdc = new(g); return DrawPopupBorder(hdc, r, colors); } internal static Rectangle DrawPopupBorder(PaintEventArgs e, Rectangle r, ColorData colors) { - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); return DrawPopupBorder(hdc, r, colors); } @@ -324,7 +324,7 @@ private static Bitmap GetCheckBoxImage(Color checkColor, Rectangle fullSize, ref using (Graphics offscreen = Graphics.FromImage(bitmap)) { offscreen.Clear(Color.Transparent); - using var hdc = new DeviceContextHdcScope(offscreen, applyGraphicsState: false); + using DeviceContextHdcScope hdc = new(offscreen, applyGraphicsState: false); PInvoke.DrawFrameControl( hdc, ref rcCheck, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxStandardAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxStandardAdapter.cs index 91530cdd2b3..4e3129d482c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxStandardAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckBoxStandardAdapter.cs @@ -96,7 +96,7 @@ internal override Size GetPreferredSizeCore(Size proposedSize) { LayoutOptions? options = default; using (var screen = GdiCache.GetScreenHdc()) - using (PaintEventArgs pe = new PaintEventArgs(screen, default(Rectangle))) + using (PaintEventArgs pe = new PaintEventArgs(screen, default)) { options = Layout(pe); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckableControlBaseAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckableControlBaseAdapter.cs index 757f7551ac1..bd2d295b3cd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckableControlBaseAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/CheckableControlBaseAdapter.cs @@ -38,7 +38,7 @@ internal override Size GetPreferredSizeCore(Size proposedSize) LayoutOptions? options = default; using (var screen = GdiCache.GetScreenHdc()) - using (PaintEventArgs pe = new PaintEventArgs(screen, default(Rectangle))) + using (PaintEventArgs pe = new PaintEventArgs(screen, default)) { options = Layout(pe); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonBaseAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonBaseAdapter.cs index c6adb44f316..9973da3ad0a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonBaseAdapter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonInternal/RadioButtonBaseAdapter.cs @@ -202,7 +202,7 @@ protected void DrawCheckBox(PaintEventArgs e, LayoutData layout) if (Application.RenderWithVisualStyles) { - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); RadioButtonRenderer.DrawRadioButtonWithVisualStyles( hdc, new Point(check.Left, check.Top), diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonRenderer.cs index e2987c5e5f7..997cc1e242b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ButtonRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ButtonRenderer.cs @@ -106,7 +106,7 @@ internal static void DrawButtonForHandle( { InitializeRenderer((int)state); - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); t_visualStyleRenderer.DrawBackground(hdc, bounds, hwnd); contentBounds = t_visualStyleRenderer.GetBackgroundContentRectangle(hdc, bounds); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.cs index ac75c2b6219..ccabe8d22c7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBox.cs @@ -21,9 +21,9 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionCheckBox))] public partial class CheckBox : ButtonBase { - private static readonly object EVENT_CHECKEDCHANGED = new object(); - private static readonly object EVENT_CHECKSTATECHANGED = new object(); - private static readonly object EVENT_APPEARANCECHANGED = new object(); + private static readonly object EVENT_CHECKEDCHANGED = new(); + private static readonly object EVENT_CHECKSTATECHANGED = new(); + private static readonly object EVENT_APPEARANCECHANGED = new(); private const ContentAlignment AnyRight = ContentAlignment.TopRight | ContentAlignment.MiddleRight | ContentAlignment.BottomRight; private ContentAlignment _checkAlign = ContentAlignment.MiddleLeft; @@ -280,7 +280,7 @@ protected override CreateParams CreateParams } } - protected override Size DefaultSize => new Size(104, 24); + protected override Size DefaultSize => new(104, 24); /// /// When overridden in a derived class, handles rescaling of any magic numbers used in control painting. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBoxRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBoxRenderer.cs index 927530d3c18..e3edc44b724 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckBoxRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckBoxRenderer.cs @@ -89,7 +89,7 @@ internal static void DrawCheckBoxWithVisualStyles( { InitializeRenderer((int)state); - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); Rectangle glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); t_visualStyleRenderer.DrawBackground(hdc, glyphBounds, hwnd); } @@ -260,7 +260,7 @@ internal static Size GetGlyphSize(IDeviceContext deviceContext, CheckBoxState st return new Size(13, 13); } - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); return GetGlyphSize(hdc, state, hwnd); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.cs index 3522b6a154e..f464f52e17b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CheckedListBox.cs @@ -394,7 +394,7 @@ private unsafe void InvalidateItem(int index) { if (IsHandleCreated) { - var rect = default(RECT); + RECT rect = default; PInvoke.SendMessage(this, PInvoke.LB_GETITEMRECT, (WPARAM)index, ref rect); PInvoke.InvalidateRect(this, &rect, bErase: false); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ColorDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ColorDialog.cs index 46f99b2325b..489a2ef81b0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ColorDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ColorDialog.cs @@ -162,7 +162,7 @@ protected override unsafe bool RunDialog(IntPtr hwndOwner) { WNDPROC hookProc = HookProcInternal; void* hookProcPtr = (void*)Marshal.GetFunctionPointerForDelegate(hookProc); - var cc = new Comdlg32.CHOOSECOLORW + Comdlg32.CHOOSECOLORW cc = new() { lStructSize = (uint)Marshal.SizeOf() }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs index 1209cfeb906..87d27d25ba7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs @@ -25,15 +25,15 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionComboBox))] public partial class ComboBox : ListControl { - private static readonly object EVENT_DROPDOWN = new object(); - private static readonly object EVENT_DRAWITEM = new object(); - private static readonly object EVENT_MEASUREITEM = new object(); - private static readonly object EVENT_SELECTEDINDEXCHANGED = new object(); - private static readonly object EVENT_SELECTIONCHANGECOMMITTED = new object(); - private static readonly object EVENT_SELECTEDITEMCHANGED = new object(); - private static readonly object EVENT_DROPDOWNSTYLE = new object(); - private static readonly object EVENT_TEXTUPDATE = new object(); - private static readonly object EVENT_DROPDOWNCLOSED = new object(); + private static readonly object EVENT_DROPDOWN = new(); + private static readonly object EVENT_DRAWITEM = new(); + private static readonly object EVENT_MEASUREITEM = new(); + private static readonly object EVENT_SELECTEDINDEXCHANGED = new(); + private static readonly object EVENT_SELECTIONCHANGECOMMITTED = new(); + private static readonly object EVENT_SELECTEDITEMCHANGED = new(); + private static readonly object EVENT_DROPDOWNSTYLE = new(); + private static readonly object EVENT_TEXTUPDATE = new(); + private static readonly object EVENT_DROPDOWNCLOSED = new(); private static readonly int PropMaxLength = PropertyStore.CreateKey(); private static readonly int PropItemHeight = PropertyStore.CreateKey(); @@ -88,7 +88,7 @@ public partial class ComboBox : ListControl private string _currentText = string.Empty; private string? _lastTextChangedValue; private bool _dropDown; - private readonly AutoCompleteDropDownFinder _finder = new AutoCompleteDropDownFinder(); + private readonly AutoCompleteDropDownFinder _finder = new(); private bool _selectedValueChangedFired; private AutoCompleteMode _autoCompleteMode = AutoCompleteMode.None; @@ -3740,7 +3740,7 @@ private unsafe void WmReflectDrawItem(ref Message m) { DRAWITEMSTRUCT* dis = (DRAWITEMSTRUCT*)(nint)m.LParamInternal; - using var e = new DrawItemEventArgs( + using DrawItemEventArgs e = new( dis->hDC, Font, dis->rcItem, @@ -4005,5 +4005,5 @@ private FlatComboAdapter FlatComboBoxAdapter } internal virtual FlatComboAdapter CreateFlatComboAdapterInstance() - => new FlatComboAdapter(this, smallButton: false); + => new(this, smallButton: false); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxRenderer.cs index 1938ab8a070..7f67c38c974 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComboBoxRenderer.cs @@ -98,7 +98,7 @@ public static void DrawTextBox(Graphics g, Rectangle bounds, string? comboBoxTex /// public static void DrawDropDownButton(Graphics g, Rectangle bounds, ComboBoxState state) { - using var hdc = new DeviceContextHdcScope(g); + using DeviceContextHdcScope hdc = new(g); DrawDropDownButtonForHandle(hdc, bounds, state, HWND.Null); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Command.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Command.cs index 3eb2a06e2c0..6bccae33f0e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Command.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Command.cs @@ -8,7 +8,7 @@ internal class Command : WeakReference { private static Command?[]? s_cmds; private static int s_icmdTry; - private static readonly object s_internalSyncObject = new object(); + private static readonly object s_internalSyncObject = new(); private const int IdMin = 0x00100; private const int IdLim = 0x10000; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs index acda24df4fa..d2f0732fc7d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2IManagedPerPropertyBrowsingHandler.cs @@ -221,7 +221,7 @@ private static string[] GetStringsFromPtr(BSTR* values, uint count) private static unsafe object?[] GetVariantsFromPtr(VARIANT* values, uint count) { - var objects = new object?[count]; + object?[] objects = new object?[count]; for (int i = 0; i < count; i++) { try diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2TypeInfoProcessor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2TypeInfoProcessor.cs index 9e0ea1dbd2a..39605c65db4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2TypeInfoProcessor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/COM2TypeInfoProcessor.cs @@ -508,8 +508,8 @@ private static unsafe PropertyInfo ProcessDataCore( VARFLAGS flags) { // Get the name and the helpstring. - using var nameBstr = default(BSTR); - using var helpStringBstr = default(BSTR); + using BSTR nameBstr = default; + using BSTR helpStringBstr = default; HRESULT hr = typeInfo->GetDocumentation(dispid, &nameBstr, &helpStringBstr, null, null); if (!hr.Succeeded) { @@ -738,8 +738,8 @@ private static unsafe void ProcessFunctions( object? varValue = null; - using var enumNameBstr = default(BSTR); - using var enumHelpStringBstr = default(BSTR); + using BSTR enumNameBstr = default; + using BSTR enumHelpStringBstr = default; enumTypeInfo->GetDocumentation(PInvoke.MEMBERID_NIL, &enumNameBstr, &enumHelpStringBstr, null, null); // For each item in the enum type info, we just need it's name and value and diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.ComTypeDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.ComTypeDescriptor.cs index 2561374f87c..9c32678a612 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.ComTypeDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ComponentModel/COM2Interop/ComNativeDescriptor.ComTypeDescriptor.cs @@ -46,10 +46,10 @@ internal ComTypeDescriptor(ComNativeDescriptor handler, object instance) [RequiresUnreferencedCode(EditorRequiresUnreferencedCode)] object? ICustomTypeDescriptor.GetEditor(Type editorBaseType) => GetEditor(_instance, editorBaseType); - EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => new EventDescriptorCollection(null); + EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => new(null); [RequiresUnreferencedCode(FilterRequiresUnreferencedCodeMessage)] - EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[]? attributes) => new EventDescriptorCollection(null); + EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[]? attributes) => new(null); [RequiresUnreferencedCode(PropertyDescriptorPropertyTypeMessage)] PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() => _handler.GetProperties(_instance); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs index 86ddc2e5f27..e81b5ed852a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs @@ -726,7 +726,7 @@ internal override Rectangle GetToolNativeScreenRectangle() { // Get window's client rectangle (i.e. without chrome) expressed in screen coordinates PInvoke.GetClientRect(this, out RECT clientRectangle); - var topLeftPoint = default(Point); + Point topLeftPoint = default; PInvoke.ClientToScreen(this, ref topLeftPoint); return new Rectangle(topLeftPoint.X, topLeftPoint.Y, clientRectangle.right, clientRectangle.bottom); } @@ -744,7 +744,7 @@ private unsafe SizeF GetFontAutoScaleDimensions(HFONT fontHandle) // Windows uses CreateCompatibleDC(NULL) to get a memory DC for // the monitor the application is currently on. - using var dc = new PInvoke.CreateDcScope(default); + using PInvoke.CreateDcScope dc = new(default); if (dc.IsNull) { throw new Win32Exception(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs index 2fefc0dee9e..50adab0d64b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ActiveXImpl.cs @@ -346,11 +346,7 @@ internal unsafe HRESULT DoVerb( { // Must translate message coordinates over to our HWND. HWND hwndMap = hwnd.IsNull ? hwndParent : hwnd; - var pt = new Point - { - X = PARAM.LOWORD(lpmsg->lParam), - Y = PARAM.HIWORD(lpmsg->lParam) - }; + Point pt = new(PARAM.LOWORD(lpmsg->lParam), PARAM.HIWORD(lpmsg->lParam)); PInvoke.MapWindowPoints(hwndMap, _control, ref pt); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ThreadMethodEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ThreadMethodEntry.cs index 30f8bf9000e..674dd17bad0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ThreadMethodEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ThreadMethodEntry.cs @@ -19,7 +19,7 @@ private class ThreadMethodEntry : IAsyncResult internal Exception? _exception; internal bool _synchronous; private ManualResetEvent? _resetEvent; - private readonly object _invokeSyncObject = new object(); + private readonly object _invokeSyncObject = new(); // Store the execution context associated with the caller thread, and // information about which thread actually got the stack applied to it. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs index ead40be032d..8911a378093 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs @@ -126,76 +126,76 @@ private protected void TraceCanProcessMnemonic() private static readonly uint WM_GETCONTROLNAME = PInvoke.RegisterWindowMessage("WM_GETCONTROLNAME"); private static readonly uint WM_GETCONTROLTYPE = PInvoke.RegisterWindowMessage("WM_GETCONTROLTYPE"); - private static readonly object s_autoSizeChangedEvent = new object(); - private static readonly object s_keyDownEvent = new object(); - private static readonly object s_keyPressEvent = new object(); - private static readonly object s_keyUpEvent = new object(); - private static readonly object s_mouseDownEvent = new object(); - private static readonly object s_mouseEnterEvent = new object(); - private static readonly object s_mouseLeaveEvent = new object(); - private static readonly object s_dpiChangedBeforeParentEvent = new object(); - private static readonly object s_dpiChangedAfterParentEvent = new object(); - private static readonly object s_mouseHoverEvent = new object(); - private static readonly object s_mouseMoveEvent = new object(); - private static readonly object s_mouseUpEvent = new object(); - private static readonly object s_mouseWheelEvent = new object(); - private static readonly object s_clickEvent = new object(); - private static readonly object s_clientSizeEvent = new object(); - private static readonly object s_doubleClickEvent = new object(); - private static readonly object s_mouseClickEvent = new object(); - private static readonly object s_mouseDoubleClickEvent = new object(); - private static readonly object s_mouseCaptureChangedEvent = new object(); - private static readonly object s_moveEvent = new object(); - private static readonly object s_resizeEvent = new object(); - private static readonly object s_layoutEvent = new object(); - private static readonly object s_gotFocusEvent = new object(); - private static readonly object s_lostFocusEvent = new object(); - private static readonly object s_enterEvent = new object(); - private static readonly object s_leaveEvent = new object(); - private static readonly object s_handleCreatedEvent = new object(); - private static readonly object s_handleDestroyedEvent = new object(); - private static readonly object s_controlAddedEvent = new object(); - private static readonly object s_controlRemovedEvent = new object(); - private static readonly object s_changeUICuesEvent = new object(); - private static readonly object s_systemColorsChangedEvent = new object(); - private static readonly object s_validatingEvent = new object(); - private static readonly object s_validatedEvent = new object(); - private static readonly object s_styleChangedEvent = new object(); - private static readonly object s_imeModeChangedEvent = new object(); - private static readonly object s_helpRequestedEvent = new object(); - private static readonly object s_paintEvent = new object(); - private static readonly object s_invalidatedEvent = new object(); - private static readonly object s_queryContinueDragEvent = new object(); - private static readonly object s_giveFeedbackEvent = new object(); - private static readonly object s_dragEnterEvent = new object(); - private static readonly object s_dragLeaveEvent = new object(); - private static readonly object s_dragOverEvent = new object(); - private static readonly object s_dragDropEvent = new object(); - private static readonly object s_queryAccessibilityHelpEvent = new object(); - private static readonly object s_backgroundImageEvent = new object(); - private static readonly object s_backgroundImageLayoutEvent = new object(); - private static readonly object s_bindingContextEvent = new object(); - private static readonly object s_backColorEvent = new object(); - private static readonly object s_parentEvent = new object(); - private static readonly object s_visibleEvent = new object(); - private static readonly object s_textEvent = new object(); - private static readonly object s_tabStopEvent = new object(); - private static readonly object s_tabIndexEvent = new object(); - private static readonly object s_sizeEvent = new object(); - private static readonly object s_rightToLeftEvent = new object(); - private static readonly object s_locationEvent = new object(); - private static readonly object s_foreColorEvent = new object(); - private static readonly object s_fontEvent = new object(); - private static readonly object s_enabledEvent = new object(); - private static readonly object s_dockEvent = new object(); - private static readonly object s_cursorEvent = new object(); - private static readonly object s_contextMenuStripEvent = new object(); - private static readonly object s_causesValidationEvent = new object(); - private static readonly object s_regionChangedEvent = new object(); - private static readonly object s_marginChangedEvent = new object(); - private protected static readonly object s_paddingChangedEvent = new object(); - private static readonly object s_previewKeyDownEvent = new object(); - private static readonly object s_dataContextEvent = new object(); + private static readonly object s_autoSizeChangedEvent = new(); + private static readonly object s_keyDownEvent = new(); + private static readonly object s_keyPressEvent = new(); + private static readonly object s_keyUpEvent = new(); + private static readonly object s_mouseDownEvent = new(); + private static readonly object s_mouseEnterEvent = new(); + private static readonly object s_mouseLeaveEvent = new(); + private static readonly object s_dpiChangedBeforeParentEvent = new(); + private static readonly object s_dpiChangedAfterParentEvent = new(); + private static readonly object s_mouseHoverEvent = new(); + private static readonly object s_mouseMoveEvent = new(); + private static readonly object s_mouseUpEvent = new(); + private static readonly object s_mouseWheelEvent = new(); + private static readonly object s_clickEvent = new(); + private static readonly object s_clientSizeEvent = new(); + private static readonly object s_doubleClickEvent = new(); + private static readonly object s_mouseClickEvent = new(); + private static readonly object s_mouseDoubleClickEvent = new(); + private static readonly object s_mouseCaptureChangedEvent = new(); + private static readonly object s_moveEvent = new(); + private static readonly object s_resizeEvent = new(); + private static readonly object s_layoutEvent = new(); + private static readonly object s_gotFocusEvent = new(); + private static readonly object s_lostFocusEvent = new(); + private static readonly object s_enterEvent = new(); + private static readonly object s_leaveEvent = new(); + private static readonly object s_handleCreatedEvent = new(); + private static readonly object s_handleDestroyedEvent = new(); + private static readonly object s_controlAddedEvent = new(); + private static readonly object s_controlRemovedEvent = new(); + private static readonly object s_changeUICuesEvent = new(); + private static readonly object s_systemColorsChangedEvent = new(); + private static readonly object s_validatingEvent = new(); + private static readonly object s_validatedEvent = new(); + private static readonly object s_styleChangedEvent = new(); + private static readonly object s_imeModeChangedEvent = new(); + private static readonly object s_helpRequestedEvent = new(); + private static readonly object s_paintEvent = new(); + private static readonly object s_invalidatedEvent = new(); + private static readonly object s_queryContinueDragEvent = new(); + private static readonly object s_giveFeedbackEvent = new(); + private static readonly object s_dragEnterEvent = new(); + private static readonly object s_dragLeaveEvent = new(); + private static readonly object s_dragOverEvent = new(); + private static readonly object s_dragDropEvent = new(); + private static readonly object s_queryAccessibilityHelpEvent = new(); + private static readonly object s_backgroundImageEvent = new(); + private static readonly object s_backgroundImageLayoutEvent = new(); + private static readonly object s_bindingContextEvent = new(); + private static readonly object s_backColorEvent = new(); + private static readonly object s_parentEvent = new(); + private static readonly object s_visibleEvent = new(); + private static readonly object s_textEvent = new(); + private static readonly object s_tabStopEvent = new(); + private static readonly object s_tabIndexEvent = new(); + private static readonly object s_sizeEvent = new(); + private static readonly object s_rightToLeftEvent = new(); + private static readonly object s_locationEvent = new(); + private static readonly object s_foreColorEvent = new(); + private static readonly object s_fontEvent = new(); + private static readonly object s_enabledEvent = new(); + private static readonly object s_dockEvent = new(); + private static readonly object s_cursorEvent = new(); + private static readonly object s_contextMenuStripEvent = new(); + private static readonly object s_causesValidationEvent = new(); + private static readonly object s_regionChangedEvent = new(); + private static readonly object s_marginChangedEvent = new(); + private protected static readonly object s_paddingChangedEvent = new(); + private static readonly object s_previewKeyDownEvent = new(); + private static readonly object s_dataContextEvent = new(); private static MessageId s_threadCallbackMessage; private static ContextCallback? s_invokeMarshaledCallbackHelperDelegate; @@ -5267,7 +5267,7 @@ public void DrawToBitmap(Bitmap bitmap, Rectangle targetBounds) using Bitmap image = new Bitmap(width, height, bitmap.PixelFormat); using Graphics g = Graphics.FromImage(image); - using var hDc = new DeviceContextHdcScope(g, applyGraphicsState: false); + using DeviceContextHdcScope hDc = new(g, applyGraphicsState: false); // Send the WM_PRINT message. PInvoke.SendMessage( @@ -5278,7 +5278,7 @@ public void DrawToBitmap(Bitmap bitmap, Rectangle targetBounds) // Now BLT the result to the destination bitmap. using Graphics destGraphics = Graphics.FromImage(bitmap); - using var desthDC = new DeviceContextHdcScope(destGraphics, applyGraphicsState: false); + using DeviceContextHdcScope desthDC = new(destGraphics, applyGraphicsState: false); PInvoke.BitBlt( desthDC, targetBounds.X, @@ -6241,7 +6241,7 @@ public unsafe void Invalidate(Region? region, bool invalidateChildren) else if (IsHandleCreated) { using Graphics graphics = CreateGraphicsInternal(); - using var regionHandle = new PInvoke.RegionScope(region, graphics); + using PInvoke.RegionScope regionHandle = new(region, graphics); if (invalidateChildren) { @@ -7597,8 +7597,8 @@ protected virtual void OnPrint(PaintEventArgs e) { uint flags = PInvoke.PRF_CHILDREN | PInvoke.PRF_CLIENT | PInvoke.PRF_ERASEBKGND | PInvoke.PRF_NONCLIENT; - using var hdc = new DeviceContextHdcScope(e); - Message m = Message.Create(HWND, (uint)PInvoke.WM_PRINTCLIENT, (WPARAM)hdc, (LPARAM)flags); + using DeviceContextHdcScope hdc = new DeviceContextHdcScope(e); + Message m = Message.Create(HWND, PInvoke.WM_PRINTCLIENT, (WPARAM)hdc, (LPARAM)flags); DefWndProc(ref m); } else @@ -8725,7 +8725,7 @@ internal unsafe void PaintTransparentBackground(PaintEventArgs e, Rectangle rect if (transparentRegion is not null) { Graphics g = e.GraphicsInternal; - using var saveState = new GraphicsStateScope(g); + using GraphicsStateScope saveState = new(g); g.Clip = transparentRegion; ButtonRenderer.DrawParentBackground(g, rectangle, this); } @@ -8756,7 +8756,7 @@ internal unsafe void PaintTransparentBackground(PaintEventArgs e, Rectangle rect if (transparentRegion is not null) { - using var saveState = new GraphicsStateScope(newArgs.Graphics); + using GraphicsStateScope saveState = new GraphicsStateScope(newArgs.Graphics); // Is this clipping something we can apply directly to the HDC? newArgs.Graphics.Clip = transparentRegion; @@ -11428,7 +11428,7 @@ public void Update() [EditorBrowsable(EditorBrowsableState.Advanced)] protected internal void UpdateBounds() { - RECT rect = default(RECT); + RECT rect = default; int clientWidth = 0; int clientHeight = 0; @@ -12605,7 +12605,7 @@ private void WmQueryNewPalette(ref Message m) { s_paletteTracing.TraceVerbose($"{Handle}: WM_QUERYNEWPALETTE"); - using var dc = new GetDcScope(HWND); + using GetDcScope dc = new(HWND); // We don't want to unset the palette in this case so we don't do this in a using var paletteScope = PInvoke.SelectPaletteScope.HalftonePalette( diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ControlBindingsCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ControlBindingsCollection.cs index f25b2fd36a8..d122dfdb31b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ControlBindingsCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ControlBindingsCollection.cs @@ -89,7 +89,7 @@ public Binding Add(string propertyName, object dataSource, string dataMember, bo { ArgumentNullException.ThrowIfNull(dataSource); - var binding = new Binding(propertyName, dataSource, dataMember, formattingEnabled, updateMode, nullValue, formatString, formatInfo); + Binding binding = new(propertyName, dataSource, dataMember, formattingEnabled, updateMode, nullValue, formatString, formatInfo); Add(binding); return binding; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.cs index db36c19561c..b4cc4f9b74a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ControlPaint.cs @@ -773,7 +773,7 @@ internal static unsafe void DrawBorder( { HLSColor hlsColor = new HLSColor(topColor); float inc = InfinityToOne(1.0f / (topWidth - 1)); - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); for (int i = 0; i < topWidth; i++) { using PInvoke.CreatePenScope hpen = new( @@ -836,7 +836,7 @@ internal static unsafe void DrawBorder( { HLSColor hlsColor = new HLSColor(leftColor); float inc = InfinityToOne(1.0f / (leftWidth - 1)); - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); for (int i = 0; i < leftWidth; i++) { using PInvoke.CreatePenScope hpen = new( @@ -1081,7 +1081,7 @@ public static void DrawBorder3D(Graphics graphics, int x, int y, int width, int } // Get Win32 dc with Graphics properties applied to it. - using var hdc = new DeviceContextHdcScope(graphics); + using DeviceContextHdcScope hdc = new(graphics); PInvoke.DrawEdge(hdc, ref rc, edge, flags); } @@ -1409,7 +1409,7 @@ private static void DrawFlatCheckBox( using (Graphics g2 = Graphics.FromImage(bitmap)) { g2.Clear(Color.Transparent); - using var dc = new DeviceContextHdcScope(g2, applyGraphicsState: false); + using DeviceContextHdcScope dc = new(g2, applyGraphicsState: false); PInvoke.DrawFrameControl(dc, ref rcCheck, DFC_TYPE.DFC_MENU, DFCS_STATE.DFCS_MENUCHECK); } @@ -1482,7 +1482,7 @@ private static void DrawFrameControl( using Graphics g2 = Graphics.FromImage(bitmap); g2.Clear(Color.Transparent); - using (var hdc = new DeviceContextHdcScope(g2, applyGraphicsState: false)) + using (DeviceContextHdcScope hdc = new(g2, applyGraphicsState: false)) { // Get Win32 dc with Graphics properties applied to it. PInvoke.DrawFrameControl(hdc, ref rcFrame, kind, state); @@ -1496,13 +1496,13 @@ private static void DrawFrameControl( { // Replace black/white with foreColor/backColor. ImageAttributes attrs = new ImageAttributes(); - ColorMap cm1 = new ColorMap + ColorMap cm1 = new() { OldColor = Color.Black, NewColor = foreColor }; - ColorMap cm2 = new ColorMap + ColorMap cm2 = new() { OldColor = Color.White, NewColor = backColor @@ -1605,7 +1605,7 @@ internal static void DrawImageColorized( { ArgumentNullException.ThrowIfNull(graphics); - using var attributes = new ImageAttributes(); + using ImageAttributes attributes = new(); attributes.SetColorMatrix(RemapBlackAndWhitePreserveTransparentMatrix(replaceBlack, Color.White)); graphics.DrawImage( image, @@ -1624,9 +1624,9 @@ internal static bool IsImageTransparent(Image? backgroundImage) // the supplied Graphics object. internal static void DrawImageReplaceColor(Graphics g, Image image, Rectangle dest, Color oldColor, Color newColor) { - ImageAttributes attrs = new ImageAttributes(); + ImageAttributes attrs = new(); - ColorMap cm = new ColorMap + ColorMap cm = new() { OldColor = oldColor, NewColor = newColor @@ -1683,8 +1683,8 @@ internal static void DrawImageDisabled(Graphics graphics, Image image, Rectangle if (unscaledImage) { - using Bitmap bmp = new Bitmap(image.Width, image.Height); - using (Graphics g = Graphics.FromImage(bmp)) + using Bitmap bitmap = new(image.Width, image.Height); + using (Graphics g = Graphics.FromImage(bitmap)) { g.DrawImage( image, @@ -1694,7 +1694,7 @@ internal static void DrawImageDisabled(Graphics graphics, Image image, Rectangle t_disabledImageAttr); } - graphics.DrawImageUnscaled(bmp, imageBounds); + graphics.DrawImageUnscaled(bitmap, imageBounds); } else { @@ -2036,7 +2036,7 @@ public static void DrawStringDisabled( // This must come before creating the scope. FONT_QUALITY quality = TextRenderer.FontQualityFromTextRenderingHint(dc); - using var hdc = new DeviceContextHdcScope(dc, TextRenderer.GetApplyStateFlags(dc, format)); + using DeviceContextHdcScope hdc = new(dc, TextRenderer.GetApplyStateFlags(dc, format)); DrawStringDisabled(hdc, s, font, color, layoutRectangle, format, quality); } @@ -2090,7 +2090,7 @@ public static void FillReversibleRectangle(Rectangle rectangle, Color backColor) 0x5a0049); // RasterOp.BRUSH.XorWith(RasterOp.TARGET)); R2_MODE rop2 = R2_MODE.R2_NOT; - using var desktopDC = new GetDcScope( + using GetDcScope desktopDC = new( PInvoke.GetDesktopWindow(), HRGN.Null, GET_DCX_FLAGS.DCX_WINDOW | GET_DCX_FLAGS.DCX_LOCKWINDOWUPDATE | GET_DCX_FLAGS.DCX_CACHE); @@ -2109,7 +2109,7 @@ public static void FillReversibleRectangle(Rectangle rectangle, Color backColor) /// function -- when used on something not obtained from ChooseFont, it may round away some precision. /// internal static Font FontInPoints(Font font) - => new Font( + => new( font.FontFamily, font.SizeInPoints, font.Style, @@ -2468,7 +2468,7 @@ internal static void InvertForeColorIfNeeded(Bitmap bitmap, Color backgroundColo var pixel = bitmap.GetPixel(x, y); if (pixel != backgroundColor) { - var pixelColorWrapper = new HLSColor(pixel); + HLSColor pixelColorWrapper = new(pixel); if (Math.Abs(pixelColorWrapper.Luminosity - backgroundColorWrapper.Luminosity) > MaximumLuminosityDifference) { bitmap.SetPixel(x, y, pixel.InvertColor()); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/CurrencyManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/CurrencyManager.cs index 4f22cebb5ac..6b11a321054 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/CurrencyManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/CurrencyManager.cs @@ -30,7 +30,7 @@ public class CurrencyManager : BindingManagerBase private bool suspendPushDataInCurrentChanged; private ItemChangedEventHandler onItemChanged; private ListChangedEventHandler onListChanged; - private readonly ItemChangedEventArgs resetEvent = new ItemChangedEventArgs(-1); + private readonly ItemChangedEventArgs resetEvent = new(-1); private EventHandler onMetaDataChangedHandler; /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index f3c90caab03..5e7989243c1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -246,7 +246,7 @@ private void DrawImageCore(Graphics graphics, Rectangle imageRect, Rectangle tar targetRect.X += (int)graphics.Transform.OffsetX; targetRect.Y += (int)graphics.Transform.OffsetY; - using var dc = new DeviceContextHdcScope(graphics, applyGraphicsState: false); + using DeviceContextHdcScope dc = new(graphics, applyGraphicsState: false); int imageX = 0; int imageY = 0; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.cs index e473aa8f6e6..e6b899bf2a0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataFormats.cs @@ -148,7 +148,7 @@ public static partial class DataFormats private static Format[]? s_formatList; private static int s_formatCount; - private static readonly object s_internalSyncObject = new object(); + private static readonly object s_internalSyncObject = new(); /// /// Gets a with the Windows Clipboard numeric ID and name for the specified format. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.HitTestInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.HitTestInfo.cs index 7dc1f21da36..01da04f17c6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.HitTestInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.HitTestInfo.cs @@ -21,7 +21,7 @@ public sealed class HitTestInfo /// /// Allows the object to inform you the extent of the grid. /// - public static readonly HitTestInfo Nowhere = new HitTestInfo(); + public static readonly HitTestInfo Nowhere = new(); internal HitTestInfo() { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.Methods.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.Methods.cs index ba4fd1c5127..76840939763 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.Methods.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.Methods.cs @@ -10571,7 +10571,7 @@ private void LayoutScrollBars() } } - _layout.ResizeBoxRect = default(Rectangle); + _layout.ResizeBoxRect = default; if (needVertScrollbar && needHorizScrollbar) { _layout.ResizeBoxRect = new Rectangle( @@ -17219,7 +17219,7 @@ protected override void OnPaint(PaintEventArgs e) if (clipRect.IntersectsWith(gridRect)) { - using var clipScope = new GraphicsClipScope(g); + using GraphicsClipScope clipScope = new(g); g.SetClip(gridRect); PaintBackground(g, clipRect, gridRect); PaintGrid(g, gridRect, clipRect, SingleVerticalBorderAdded, SingleHorizontalBorderAdded); @@ -19974,7 +19974,7 @@ private void PaintColumnHeaders(Graphics g, Rectangle clipBounds, bool singleBor bool isFirstDisplayedColumn = true, isLastVisibleColumn = false; DataGridViewCell cell; DataGridViewCellStyle inheritedCellStyle = new DataGridViewCellStyle(); - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; DataGridViewColumn dataGridViewColumnNext = null; // first paint the visible frozen columns diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs index 203cfbaa5b6..ee3758e6bb8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs @@ -19,124 +19,124 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionDataGridView))] public partial class DataGridView : Control, ISupportInitialize { - private static readonly object s_allowUserToAddRowsChangedEvent = new object(); - private static readonly object s_allowUserToDeleteRowsChangedEvent = new object(); - private static readonly object s_allowUserToOrderColumnsChangedEvent = new object(); - private static readonly object s_allowUserToResizeColumnsChangedEvent = new object(); - private static readonly object s_allowUserToResizeRowsChangedEvent = new object(); - private static readonly object s_alternatingRowsDefaultCellStyleChangedEvent = new object(); - private static readonly object s_autoGenerateColumnsChangedEvent = new object(); - private static readonly object s_autosizeColumnModeChangedEvent = new object(); - private static readonly object s_autosizeColumnsModeChangedEvent = new object(); - private static readonly object s_autosizeRowsModeChangedEvent = new object(); - private static readonly object s_backgroundColorChangedEvent = new object(); - private static readonly object s_borderStyleChangedEvent = new object(); - private static readonly object s_cancelRowEditEvent = new object(); - private static readonly object s_cellBeginEditEvent = new object(); - private static readonly object s_cellBorderStyleChangedEvent = new object(); - private static readonly object s_cellClickEvent = new object(); - private static readonly object s_cellContentClickEvent = new object(); - private static readonly object s_cellContentDoubleClickEvent = new object(); - private static readonly object s_cellContextMenuStripChangedEvent = new object(); - private static readonly object s_cellContextMenuStripNeededEvent = new object(); - private static readonly object s_cellDoubleClickEvent = new object(); - private static readonly object s_cellEndEditEvent = new object(); - private static readonly object s_cellEnterEvent = new object(); - private static readonly object s_cellErrorTextChangedEvent = new object(); - private static readonly object s_cellErrorTextNeededEvent = new object(); - private static readonly object s_cellFormattingEvent = new object(); - private static readonly object s_cellLeaveEvent = new object(); - private static readonly object s_cellMouseClickEvent = new object(); - private static readonly object s_cellMouseDoubleClickEvent = new object(); - private static readonly object s_cellMouseDownEvent = new object(); - private static readonly object s_cellMouseEnterEvent = new object(); - private static readonly object s_cellMouseLeaveEvent = new object(); - private static readonly object s_cellMouseMoveEvent = new object(); - private static readonly object s_cellMouseUpEvent = new object(); - private static readonly object s_cellPaintingEvent = new object(); - private static readonly object s_cellParsingEvent = new object(); - private static readonly object s_cellStateChangedEvent = new object(); - private static readonly object s_cellStyleChangedEvent = new object(); - private static readonly object s_cellStyleContentChangedEvent = new object(); - private static readonly object s_cellTooltipTextChangedEvent = new object(); - private static readonly object s_cellTooltipTextNeededEvent = new object(); - private static readonly object s_cellValidatingEvent = new object(); - private static readonly object s_cellValidatedEvent = new object(); - private static readonly object s_cellValueChangedEvent = new object(); - private static readonly object s_cellValueNeededEvent = new object(); - private static readonly object s_cellValuePushedEvent = new object(); - private static readonly object s_columnAddedEvent = new object(); - private static readonly object s_columnContextMenuStripChangedEvent = new object(); - private static readonly object s_columnDataPropertyNameChangedEvent = new object(); - private static readonly object s_columnDefaultCellStyleChangedEvent = new object(); - private static readonly object s_columnDisplayIndexChangedEvent = new object(); - private static readonly object s_columnDividerWidthChangedEvent = new object(); - private static readonly object s_columnHeaderCellChangedEvent = new object(); - private static readonly object s_columnDividerDoubleClickEvent = new object(); - private static readonly object s_columnHeaderMouseClickEvent = new object(); - private static readonly object s_columnHeaderMouseDoubleClickEvent = new object(); - private static readonly object s_columnHeadersBorderStyleChangedEvent = new object(); - private static readonly object s_columnHeadersDefaultCellStyleChangedEvent = new object(); - private static readonly object s_columnHeadersHeightChangedEvent = new object(); - private static readonly object s_columnHeadersHeightSizeModeChangedEvent = new object(); - private static readonly object s_columnMinimumWidthChangedEvent = new object(); - private static readonly object s_columnNameChangedEvent = new object(); - private static readonly object s_columnRemovedEvent = new object(); - private static readonly object s_columnSortModeChangedEvent = new object(); - private static readonly object s_columnStateChangedEvent = new object(); - private static readonly object s_columnTooltipTextChangedEvent = new object(); - private static readonly object s_columnWidthChangedEvent = new object(); - private static readonly object s_currentCellChangedEvent = new object(); - private static readonly object s_currentCellDirtyStateChangedEvent = new object(); - private static readonly object s_dataBindingCompleteEvent = new object(); - private static readonly object s_dataErrorEvent = new object(); - private static readonly object s_dataMemberChangedEvent = new object(); - private static readonly object s_dataSourceChangedEvent = new object(); - private static readonly object s_defaultCellStyleChangedEvent = new object(); - private static readonly object s_defaultValuesNeededEvent = new object(); - private static readonly object s_editingControlShowingEvent = new object(); - private static readonly object s_editModeChangedEvent = new object(); - private static readonly object s_gridColorChangedEvent = new object(); - private static readonly object s_multiselectChangedEvent = new object(); - private static readonly object s_newRowNeededEvent = new object(); - private static readonly object s_readOnlyChangedEvent = new object(); - private static readonly object s_rowContextMenuStripChangedEvent = new object(); - private static readonly object s_rowContextMenuStripNeededEvent = new object(); - private static readonly object s_rowDefaultCellStyleChangedEvent = new object(); - private static readonly object s_rowDirtyStateNeededEvent = new object(); - private static readonly object s_rowDividerHeightChangedEvent = new object(); - private static readonly object s_rowEnterEvent = new object(); - private static readonly object s_rowErrorTextChangedEvent = new object(); - private static readonly object s_rowErrorTextNeededEvent = new object(); - private static readonly object s_rowHeaderCellChangedEvent = new object(); - private static readonly object s_rowDividerDoubleClickEvent = new object(); - private static readonly object s_rowHeaderMouseClickEvent = new object(); - private static readonly object s_rowHeaderMouseDoubleClickEvent = new object(); - private static readonly object s_rowHeadersBorderStyleChangedEvent = new object(); - private static readonly object s_rowHeadersDefaultCellStyleChangedEvent = new object(); - private static readonly object s_rowHeadersWidthChangedEvent = new object(); - private static readonly object s_rowHeadersWidthSizeModeChangedEvent = new object(); - private static readonly object s_rowHeightChangedEvent = new object(); - private static readonly object s_rowHeightInfoNeededEvent = new object(); - private static readonly object s_rowHeightInfoPushedEvent = new object(); - private static readonly object s_rowLeaveEvent = new object(); - private static readonly object s_rowMinimumHeightChangeEvent = new object(); - private static readonly object s_rowPostPaintEvent = new object(); - private static readonly object s_rowPrePaintEvent = new object(); - private static readonly object s_rowsAddedEvent = new object(); - private static readonly object s_rowsDefaultCellStyleChangedEvent = new object(); - private static readonly object s_rowsRemovedEvent = new object(); - private static readonly object s_rowStateChangedEvent = new object(); - private static readonly object s_rowUnsharedEvent = new object(); - private static readonly object s_rowValidatedEvent = new object(); - private static readonly object s_rowValidatingEvent = new object(); - private static readonly object s_scrollEvent = new object(); - private static readonly object s_selectionChangedEvent = new object(); - private static readonly object s_sortCompareEvent = new object(); - private static readonly object s_sortedEvent = new object(); - private static readonly object s_userAddedRowEvent = new object(); - private static readonly object s_userDeletedRowEvent = new object(); - private static readonly object s_userDeletingRowEvent = new object(); + private static readonly object s_allowUserToAddRowsChangedEvent = new(); + private static readonly object s_allowUserToDeleteRowsChangedEvent = new(); + private static readonly object s_allowUserToOrderColumnsChangedEvent = new(); + private static readonly object s_allowUserToResizeColumnsChangedEvent = new(); + private static readonly object s_allowUserToResizeRowsChangedEvent = new(); + private static readonly object s_alternatingRowsDefaultCellStyleChangedEvent = new(); + private static readonly object s_autoGenerateColumnsChangedEvent = new(); + private static readonly object s_autosizeColumnModeChangedEvent = new(); + private static readonly object s_autosizeColumnsModeChangedEvent = new(); + private static readonly object s_autosizeRowsModeChangedEvent = new(); + private static readonly object s_backgroundColorChangedEvent = new(); + private static readonly object s_borderStyleChangedEvent = new(); + private static readonly object s_cancelRowEditEvent = new(); + private static readonly object s_cellBeginEditEvent = new(); + private static readonly object s_cellBorderStyleChangedEvent = new(); + private static readonly object s_cellClickEvent = new(); + private static readonly object s_cellContentClickEvent = new(); + private static readonly object s_cellContentDoubleClickEvent = new(); + private static readonly object s_cellContextMenuStripChangedEvent = new(); + private static readonly object s_cellContextMenuStripNeededEvent = new(); + private static readonly object s_cellDoubleClickEvent = new(); + private static readonly object s_cellEndEditEvent = new(); + private static readonly object s_cellEnterEvent = new(); + private static readonly object s_cellErrorTextChangedEvent = new(); + private static readonly object s_cellErrorTextNeededEvent = new(); + private static readonly object s_cellFormattingEvent = new(); + private static readonly object s_cellLeaveEvent = new(); + private static readonly object s_cellMouseClickEvent = new(); + private static readonly object s_cellMouseDoubleClickEvent = new(); + private static readonly object s_cellMouseDownEvent = new(); + private static readonly object s_cellMouseEnterEvent = new(); + private static readonly object s_cellMouseLeaveEvent = new(); + private static readonly object s_cellMouseMoveEvent = new(); + private static readonly object s_cellMouseUpEvent = new(); + private static readonly object s_cellPaintingEvent = new(); + private static readonly object s_cellParsingEvent = new(); + private static readonly object s_cellStateChangedEvent = new(); + private static readonly object s_cellStyleChangedEvent = new(); + private static readonly object s_cellStyleContentChangedEvent = new(); + private static readonly object s_cellTooltipTextChangedEvent = new(); + private static readonly object s_cellTooltipTextNeededEvent = new(); + private static readonly object s_cellValidatingEvent = new(); + private static readonly object s_cellValidatedEvent = new(); + private static readonly object s_cellValueChangedEvent = new(); + private static readonly object s_cellValueNeededEvent = new(); + private static readonly object s_cellValuePushedEvent = new(); + private static readonly object s_columnAddedEvent = new(); + private static readonly object s_columnContextMenuStripChangedEvent = new(); + private static readonly object s_columnDataPropertyNameChangedEvent = new(); + private static readonly object s_columnDefaultCellStyleChangedEvent = new(); + private static readonly object s_columnDisplayIndexChangedEvent = new(); + private static readonly object s_columnDividerWidthChangedEvent = new(); + private static readonly object s_columnHeaderCellChangedEvent = new(); + private static readonly object s_columnDividerDoubleClickEvent = new(); + private static readonly object s_columnHeaderMouseClickEvent = new(); + private static readonly object s_columnHeaderMouseDoubleClickEvent = new(); + private static readonly object s_columnHeadersBorderStyleChangedEvent = new(); + private static readonly object s_columnHeadersDefaultCellStyleChangedEvent = new(); + private static readonly object s_columnHeadersHeightChangedEvent = new(); + private static readonly object s_columnHeadersHeightSizeModeChangedEvent = new(); + private static readonly object s_columnMinimumWidthChangedEvent = new(); + private static readonly object s_columnNameChangedEvent = new(); + private static readonly object s_columnRemovedEvent = new(); + private static readonly object s_columnSortModeChangedEvent = new(); + private static readonly object s_columnStateChangedEvent = new(); + private static readonly object s_columnTooltipTextChangedEvent = new(); + private static readonly object s_columnWidthChangedEvent = new(); + private static readonly object s_currentCellChangedEvent = new(); + private static readonly object s_currentCellDirtyStateChangedEvent = new(); + private static readonly object s_dataBindingCompleteEvent = new(); + private static readonly object s_dataErrorEvent = new(); + private static readonly object s_dataMemberChangedEvent = new(); + private static readonly object s_dataSourceChangedEvent = new(); + private static readonly object s_defaultCellStyleChangedEvent = new(); + private static readonly object s_defaultValuesNeededEvent = new(); + private static readonly object s_editingControlShowingEvent = new(); + private static readonly object s_editModeChangedEvent = new(); + private static readonly object s_gridColorChangedEvent = new(); + private static readonly object s_multiselectChangedEvent = new(); + private static readonly object s_newRowNeededEvent = new(); + private static readonly object s_readOnlyChangedEvent = new(); + private static readonly object s_rowContextMenuStripChangedEvent = new(); + private static readonly object s_rowContextMenuStripNeededEvent = new(); + private static readonly object s_rowDefaultCellStyleChangedEvent = new(); + private static readonly object s_rowDirtyStateNeededEvent = new(); + private static readonly object s_rowDividerHeightChangedEvent = new(); + private static readonly object s_rowEnterEvent = new(); + private static readonly object s_rowErrorTextChangedEvent = new(); + private static readonly object s_rowErrorTextNeededEvent = new(); + private static readonly object s_rowHeaderCellChangedEvent = new(); + private static readonly object s_rowDividerDoubleClickEvent = new(); + private static readonly object s_rowHeaderMouseClickEvent = new(); + private static readonly object s_rowHeaderMouseDoubleClickEvent = new(); + private static readonly object s_rowHeadersBorderStyleChangedEvent = new(); + private static readonly object s_rowHeadersDefaultCellStyleChangedEvent = new(); + private static readonly object s_rowHeadersWidthChangedEvent = new(); + private static readonly object s_rowHeadersWidthSizeModeChangedEvent = new(); + private static readonly object s_rowHeightChangedEvent = new(); + private static readonly object s_rowHeightInfoNeededEvent = new(); + private static readonly object s_rowHeightInfoPushedEvent = new(); + private static readonly object s_rowLeaveEvent = new(); + private static readonly object s_rowMinimumHeightChangeEvent = new(); + private static readonly object s_rowPostPaintEvent = new(); + private static readonly object s_rowPrePaintEvent = new(); + private static readonly object s_rowsAddedEvent = new(); + private static readonly object s_rowsDefaultCellStyleChangedEvent = new(); + private static readonly object s_rowsRemovedEvent = new(); + private static readonly object s_rowStateChangedEvent = new(); + private static readonly object s_rowUnsharedEvent = new(); + private static readonly object s_rowValidatedEvent = new(); + private static readonly object s_rowValidatingEvent = new(); + private static readonly object s_scrollEvent = new(); + private static readonly object s_selectionChangedEvent = new(); + private static readonly object s_sortCompareEvent = new(); + private static readonly object s_sortedEvent = new(); + private static readonly object s_userAddedRowEvent = new(); + private static readonly object s_userDeletedRowEvent = new(); + private static readonly object s_userDeletingRowEvent = new(); private const int State1_AllowUserToAddRows = 0x00000001; private const int State1_AllowUserToDeleteRows = 0x00000002; @@ -257,8 +257,8 @@ private const DataGridViewAutoSizeRowCriteriaInternal InvalidDataGridViewAutoSiz = ~(DataGridViewAutoSizeRowCriteriaInternal.Header | DataGridViewAutoSizeRowCriteriaInternal.AllColumns); private Cursor _oldCursor; - private HScrollBar _horizScrollBar = new HScrollBar(); - private VScrollBar _vertScrollBar = new VScrollBar(); + private HScrollBar _horizScrollBar = new(); + private VScrollBar _vertScrollBar = new(); private DataGridViewHeaderCell _topLeftHeaderCell; private DataGridViewRow _rowTemplate; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.cs index 75ae1f15d74..e0c4c91d083 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewButtonCell.cs @@ -27,7 +27,7 @@ public partial class DataGridViewButtonCell : DataGridViewCell private const byte DATAGRIDVIEWBUTTONCELL_verticalTextMargin = 1; private const byte DATAGRIDVIEWBUTTONCELL_textPadding = 5; - private static Rectangle rectThemeMargins = new Rectangle(-1, -1, 0, 0); + private static Rectangle rectThemeMargins = new(-1, -1, 0, 0); private static bool mouseInContentBounds; private static readonly Type defaultFormattedValueType = typeof(string); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.cs index 8231653f71e..10571040a69 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCell.cs @@ -697,7 +697,7 @@ private protected Rectangle StdBorderWidths { if (DataGridView is not null) { - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; dgvabsEffective = AdjustCellBorderStyle( DataGridView.AdvancedCellBorderStyle, dataGridViewAdvancedBorderStylePlaceholder, @@ -1502,7 +1502,7 @@ protected virtual object GetClipboardContent(int rowIndex, sb.Append(""); if (formattedValue is not null) { - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainTextAsHtml(formattedValue.ToString(), sw); } else @@ -1539,7 +1539,7 @@ protected virtual object GetClipboardContent(int rowIndex, { bool escapeApplied = false; int insertionPoint = sb.Length; - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainText(formattedValue.ToString(), csv, sw, ref escapeApplied); if (escapeApplied) { @@ -1571,12 +1571,13 @@ protected virtual object GetClipboardContent(int rowIndex, } } - internal object GetClipboardContentInternal(int rowIndex, - bool firstCell, - bool lastCell, - bool inFirstRow, - bool inLastRow, - string format) + internal object GetClipboardContentInternal( + int rowIndex, + bool firstCell, + bool lastCell, + bool inFirstRow, + bool inLastRow, + string format) { return GetClipboardContent(rowIndex, firstCell, lastCell, inFirstRow, inLastRow, format); } @@ -3966,7 +3967,7 @@ public virtual Rectangle PositionEditingPanel(Rectangle cellBounds, throw new InvalidOperationException(); } - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; dgvabsEffective = AdjustCellBorderStyle(DataGridView.AdvancedCellBorderStyle, dataGridViewAdvancedBorderStylePlaceholder, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyle.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyle.cs index 8b3af67a577..7f9922e213f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyle.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellStyle.cs @@ -642,7 +642,7 @@ internal DataGridViewCellStyleDifferences GetDifferencesFrom(DataGridViewCellSty public override int GetHashCode() { - var hash = default(HashCode); + HashCode hash = default; hash.Add(Alignment); hash.Add(WrapMode); hash.Add(Padding); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.cs index 7bf243b9430..341587cbf6b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCheckBoxCell.cs @@ -1443,7 +1443,7 @@ private Rectangle PaintPrivate(Graphics g, using (Graphics offscreen = Graphics.FromImage(bitmap)) { offscreen.Clear(Color.Transparent); - using var hdc = new DeviceContextHdcScope(offscreen); + using DeviceContextHdcScope hdc = new(offscreen); PInvoke.DrawFrameControl( hdc, ref rcCheck, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.cs index 2be2f5bae0a..8a07ce8ab3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnCollection.cs @@ -24,7 +24,7 @@ public partial class DataGridViewColumnCollection : BaseCollection, IList private int _lastAccessedSortedIndex = -1; private int _columnCountsVisible, _columnCountsVisibleSelected; private int _columnsWidthVisible, _columnsWidthVisibleFrozen; - private static readonly ColumnOrderComparer s_columnOrderComparer = new ColumnOrderComparer(); + private static readonly ColumnOrderComparer s_columnOrderComparer = new(); /* IList interface implementation */ diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.cs index 7e652fde363..f8db6ed5a79 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewColumnHeaderCell.cs @@ -164,7 +164,7 @@ protected override object GetClipboardContent(int rowIndex, sb.Append(""); if (val is not null) { - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainTextAsHtml(val.ToString(), sw); } else @@ -195,7 +195,7 @@ protected override object GetClipboardContent(int rowIndex, { bool escapeApplied = false; int insertionPoint = sb.Length; - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainText(val.ToString(), csv, sw, ref escapeApplied); if (escapeApplied) { @@ -520,7 +520,7 @@ protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyl ArgumentNullException.ThrowIfNull(cellStyle); DataGridViewFreeDimension freeDimension = DataGridViewCell.GetFreeDimensionFromConstraint(constraintSize); - DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new(), dgvabsEffective; dgvabsEffective = DataGridView.AdjustColumnHeaderBorderStyle(DataGridView.AdvancedColumnHeadersBorderStyle, dgvabsPlaceholder, false /*isFirstDisplayedColumn*/, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.cs index 9c2665814a1..03400b0c9ef 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxCell.cs @@ -695,7 +695,7 @@ internal override void CacheEditingControl() private void CheckDropDownList(int x, int y, int rowIndex) { Debug.Assert(EditingComboBox is not null); - DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new(), dgvabsEffective; dgvabsEffective = AdjustCellBorderStyle(DataGridView.AdvancedCellBorderStyle, dgvabsPlaceholder, false /*singleVerticalBorderAdded*/, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.cs index 34dc253041d..697d3319563 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewHeaderCell.cs @@ -19,7 +19,7 @@ public partial class DataGridViewHeaderCell : DataGridViewCell private static readonly Type s_defaultFormattedValueType = typeof(string); private static readonly Type s_defaultValueType = typeof(object); private static readonly Type s_cellType = typeof(DataGridViewHeaderCell); - private static Rectangle s_rectThemeMargins = new Rectangle(-1, -1, 0, 0); + private static Rectangle s_rectThemeMargins = new(-1, -1, 0, 0); private static readonly int s_propValueType = PropertyStore.CreateKey(); private static readonly int s_propButtonState = PropertyStore.CreateKey(); private static readonly int s_propFlipXPThemesBitmap = PropertyStore.CreateKey(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.cs index a5657bbe117..dff3e264672 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRow.cs @@ -246,7 +246,7 @@ public override DataGridViewCellStyle InheritedStyle throw new InvalidOperationException(string.Format(SR.DataGridView_InvalidPropertyGetOnSharedRow, nameof(InheritedStyle))); } - var inheritedRowStyle = new DataGridViewCellStyle(); + DataGridViewCellStyle inheritedRowStyle = new(); BuildInheritedRowStyle(Index, inheritedRowStyle); return inheritedRowStyle; } @@ -1522,7 +1522,7 @@ protected internal virtual void PaintCells(Graphics graphics, DataGridViewCell cell; DataGridViewCellStyle inheritedCellStyle = new DataGridViewCellStyle(); DataGridViewColumn dataGridViewColumnNext = null; - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; // first paint the potential visible frozen cells DataGridViewColumn dataGridViewColumn = dataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen); @@ -1720,7 +1720,7 @@ protected internal virtual void PaintHeader(Graphics graphics, if (clipBounds.IntersectsWith(cellBounds)) { DataGridViewCellStyle inheritedCellStyle = new DataGridViewCellStyle(); - DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new(), dgvabsEffective; BuildInheritedRowHeaderCellStyle(inheritedCellStyle); dgvabsEffective = AdjustRowHeaderBorderStyle(dataGridView.AdvancedRowHeadersBorderStyle, dataGridViewAdvancedBorderStylePlaceholder, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.cs index 02a808a9162..809f50bee4d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowComparer.cs @@ -18,7 +18,7 @@ private partial class RowComparer private readonly int sortedColumnIndex; private readonly IComparer customComparer; private readonly bool ascending; - private static readonly ComparedObjectMax max = new ComparedObjectMax(); + private static readonly ComparedObjectMax max = new(); public RowComparer(DataGridViewRowCollection dataGridViewRows, IComparer customComparer, bool ascending) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.cs index 30b1e7d5bfa..fea43a5a71f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowHeaderCell.cs @@ -202,7 +202,7 @@ protected override object GetClipboardContent(int rowIndex, if (val is not null) { sb.Append(""); - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainTextAsHtml(val.ToString(), sw); sb.Append(""); } @@ -234,7 +234,7 @@ protected override object GetClipboardContent(int rowIndex, { bool escapeApplied = false; int insertionPoint = sb.Length; - using var sw = new StringWriter(sb, CultureInfo.CurrentCulture); + using StringWriter sw = new(sb, CultureInfo.CurrentCulture); FormatPlainText(val.ToString(), csv, sw, ref escapeApplied); if (escapeApplied) { @@ -597,7 +597,7 @@ protected override Size GetPreferredSize(Graphics graphics, DataGridViewCellStyl ArgumentNullException.ThrowIfNull(cellStyle); - DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective; + DataGridViewAdvancedBorderStyle dgvabsPlaceholder = new(), dgvabsEffective; dgvabsEffective = OwningRow.AdjustRowHeaderBorderStyle(DataGridView.AdvancedRowHeadersBorderStyle, dgvabsPlaceholder, false /*singleVerticalBorderAdded*/, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.DataStore.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.DataStore.cs index d5162233e32..6bf011dccf6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.DataStore.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.DataStore.cs @@ -25,7 +25,7 @@ public DataStoreEntry(object? data, bool autoConvert) } } - private readonly Dictionary _data = new Dictionary(BackCompatibleStringComparer.Default); + private readonly Dictionary _data = new(BackCompatibleStringComparer.Default); public DataStore() { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.FormatEnumerator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.FormatEnumerator.cs index f0ca3565cba..a376e5926f9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.FormatEnumerator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataObject.FormatEnumerator.cs @@ -16,7 +16,7 @@ public partial class DataObject private unsafe class FormatEnumerator : ComTypes.IEnumFORMATETC, IEnumFORMATETC.Interface, IManagedWrapper { private readonly IDataObject _parent; - private readonly List _formats = new List(); + private readonly List _formats = new(); private int _current; public FormatEnumerator(IDataObject parent) : this(parent, parent.GetFormats()) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataStreamFromComStream.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataStreamFromComStream.cs index f57c5f98c08..ab43a9c9afb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataStreamFromComStream.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataStreamFromComStream.cs @@ -57,7 +57,7 @@ public override int Read(byte[] buffer, int index, int count) int bytesRead = 0; if (count > 0 && index >= 0 && (count + index) <= buffer.Length) { - var span = new Span(buffer, index, count); + Span span = new(buffer, index, count); bytesRead = Read(span); } @@ -110,7 +110,7 @@ public override void Write(byte[] buffer, int index, int count) if (count > 0 && index >= 0 && (count + index) <= buffer.Length) { - var span = new ReadOnlySpan(buffer, index, count); + ReadOnlySpan span = new(buffer, index, count); Write(span); return; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.cs index f2544e98653..d926237bb8c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DateTimePicker.cs @@ -338,9 +338,9 @@ public bool Checked // The information from win32 DateTimePicker is reliable only when ShowCheckBoxes is True if (ShowCheckBox && IsHandleCreated) { - var sys = default(SYSTEMTIME); - NMDATETIMECHANGE_FLAGS gdt = (NMDATETIMECHANGE_FLAGS)PInvoke.SendMessage(this, PInvoke.DTM_GETSYSTEMTIME, 0, ref sys); - return gdt == NMDATETIMECHANGE_FLAGS.GDT_VALID; + SYSTEMTIME systemTime = default; + nint result = PInvoke.SendMessage(this, PInvoke.DTM_GETSYSTEMTIME, 0, ref systemTime); + return result == (nint)NMDATETIMECHANGE_FLAGS.GDT_VALID; } else { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.PageSelector.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.PageSelector.cs index aa04612c684..00cf48f8284 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.PageSelector.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.PageSelector.cs @@ -94,8 +94,8 @@ private unsafe void DrawTreeItem( COLORREF backColor, COLORREF textColor) { - Size size = default(Size); - RECT rc2 = default(RECT); + Size size = default; + RECT rc2 = default; RECT rc = rcIn; ImageList imagelist = ImageList; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.cs index 67a8aa1263d..e6f288605d1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ComponentEditorForm.cs @@ -23,7 +23,7 @@ public partial class ComponentEditorForm : Form private bool _dirty; private bool _firstActivate; - private readonly Panel _pageHost = new Panel(); + private readonly Panel _pageHost = new(); private PageSelector _selector; private ImageList _selectorImageList; private Button _okButton; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripItemDesignerAvailabilityAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripItemDesignerAvailabilityAttribute.cs index 67cf29ddd7b..3efdb901c60 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripItemDesignerAvailabilityAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Design/ToolStripItemDesignerAvailabilityAttribute.cs @@ -7,7 +7,7 @@ namespace System.Windows.Forms.Design; [AttributeUsage(AttributeTargets.Class)] public sealed class ToolStripItemDesignerAvailabilityAttribute : Attribute { - public static readonly ToolStripItemDesignerAvailabilityAttribute Default = new ToolStripItemDesignerAvailabilityAttribute(); + public static readonly ToolStripItemDesignerAvailabilityAttribute Default = new(); /// /// Specifies which ToolStrip types the Item can appear in - ToolStrip,MenuStrip,StatusStrip,ContextMenuStrip diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DockingAttribute.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DockingAttribute.cs index 56ee5715337..a66d95b22f6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DockingAttribute.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DockingAttribute.cs @@ -20,7 +20,7 @@ public DockingAttribute(DockingBehavior dockingBehavior) DockingBehavior = dockingBehavior; } - public static readonly DockingAttribute Default = new DockingAttribute(); + public static readonly DockingAttribute Default = new(); public DockingBehavior DockingBehavior { get; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventArgs.cs index f64791804e9..b09fa2ac7a3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DrawListViewColumnHeaderEventArgs.cs @@ -88,7 +88,7 @@ public void DrawBackground() { if (Application.RenderWithVisualStyles) { - var vsr = new VisualStyleRenderer(VisualStyleElement.Header.Item.Normal); + VisualStyleRenderer vsr = new(VisualStyleElement.Header.Item.Normal); vsr.DrawBackground(Graphics, Bounds); } else diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.cs index 3b8b93c65ea..d98166fc5fa 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.ErrorWindow.cs @@ -22,7 +22,7 @@ internal partial class ErrorWindow : NativeWindow { private static readonly int s_accessibilityProperty = PropertyStore.CreateKey(); - private readonly List _items = new List(); + private readonly List _items = new(); private readonly Control _parent; private readonly ErrorProvider _provider; private Rectangle _windowBounds; @@ -71,7 +71,7 @@ public void Add(ControlItem item) if (_tipWindow is not null) { - var toolInfo = new ComCtl32.ToolInfoWrapper(this, item.Id, TOOLTIP_FLAGS.TTF_SUBCLASS, item.Error); + ComCtl32.ToolInfoWrapper toolInfo = new(this, item.Id, TOOLTIP_FLAGS.TTF_SUBCLASS, item.Error); toolInfo.SendMessage(_tipWindow, PInvoke.TTM_ADDTOOLW); } @@ -287,7 +287,7 @@ public void Remove(ControlItem item) if (_tipWindow is not null) { - var info = new ComCtl32.ToolInfoWrapper(this, item.Id); + ComCtl32.ToolInfoWrapper info = new(this, item.Id); info.SendMessage(_tipWindow, PInvoke.TTM_DELTOOLW); } @@ -338,17 +338,10 @@ public unsafe void Update(bool timerCaused) { ControlItem item = _items[i]; Rectangle iconBounds = item.GetIconBounds(size); - if (_windowBounds.IsEmpty) - { - _windowBounds = iconBounds; - } - else - { - _windowBounds = Rectangle.Union(_windowBounds, iconBounds); - } + _windowBounds = _windowBounds.IsEmpty ? iconBounds : Rectangle.Union(_windowBounds, iconBounds); } - using var windowRegion = new Region(new Rectangle(0, 0, 0, 0)); + using Region windowRegion = new(new Rectangle(0, 0, 0, 0)); for (int i = 0; i < _items.Count; i++) { @@ -389,7 +382,7 @@ public unsafe void Update(bool timerCaused) flags |= TOOLTIP_FLAGS.TTF_RTLREADING; } - var toolInfo = new ComCtl32.ToolInfoWrapper(this, item.Id, flags, item.Error, iconBounds); + ComCtl32.ToolInfoWrapper toolInfo = new(this, item.Id, flags, item.Error, iconBounds); toolInfo.SendMessage(_tipWindow, PInvoke.TTM_SETTOOLINFOW); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs index b71ebacb4fb..035d96ee532 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs @@ -555,8 +555,7 @@ private static Icon DefaultIcon // Error provider uses small Icon. int width = PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CXSMICON); int height = PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CYSMICON); - using var defaultIcon = new Icon(typeof(ErrorProvider), "Error"); - + using Icon defaultIcon = new(typeof(ErrorProvider), "Error"); t_defaultIcon = new Icon(defaultIcon, width, height); } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FolderBrowserDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FolderBrowserDialog.cs index d04bc5127e3..0c6034a8646 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FolderBrowserDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FolderBrowserDialog.cs @@ -421,7 +421,7 @@ private unsafe bool RunDialogOld(HWND hWndOwner) fixed (char* pDisplayName = displayName) fixed (char* title = _descriptionText) { - var bi = new BROWSEINFOW + BROWSEINFOW bi = new() { pidlRoot = listHandle, hwndOwner = hWndOwner, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FontDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FontDialog.cs index 1bc50693bd7..93e7783b79b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FontDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FontDialog.cs @@ -19,7 +19,7 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionFontDialog))] public class FontDialog : CommonDialog { - protected static readonly object EventApply = new object(); + protected static readonly object EventApply = new(); private const int defaultMinSize = 0; private const int defaultMaxSize = 0; @@ -430,7 +430,7 @@ protected override unsafe bool RunDialog(IntPtr hWndOwner) using Graphics graphics = Graphics.FromHdcInternal(dc); LOGFONTW logFont = LOGFONTW.FromFont(Font, graphics); - var cf = new Comdlg32.CHOOSEFONTW + Comdlg32.CHOOSEFONTW cf = new() { lStructSize = (uint)sizeof(Comdlg32.CHOOSEFONTW), hwndOwner = hWndOwner, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs index 84c91b52bae..589699eb42f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs @@ -27,26 +27,26 @@ namespace System.Windows.Forms; [DesignerCategory("Form")] public partial class Form : ContainerControl { - private static readonly object EVENT_ACTIVATED = new object(); - private static readonly object EVENT_CLOSING = new object(); - private static readonly object EVENT_CLOSED = new object(); - private static readonly object EVENT_FORMCLOSING = new object(); - private static readonly object EVENT_FORMCLOSED = new object(); - private static readonly object EVENT_DEACTIVATE = new object(); - private static readonly object EVENT_LOAD = new object(); - private static readonly object EVENT_MDI_CHILD_ACTIVATE = new object(); - private static readonly object EVENT_INPUTLANGCHANGE = new object(); - private static readonly object EVENT_INPUTLANGCHANGEREQUEST = new object(); - private static readonly object EVENT_MENUSTART = new object(); - private static readonly object EVENT_MENUCOMPLETE = new object(); - private static readonly object EVENT_MAXIMUMSIZECHANGED = new object(); - private static readonly object EVENT_MINIMUMSIZECHANGED = new object(); - private static readonly object EVENT_HELPBUTTONCLICKED = new object(); - private static readonly object EVENT_SHOWN = new object(); - private static readonly object EVENT_RESIZEBEGIN = new object(); - private static readonly object EVENT_RESIZEEND = new object(); - private static readonly object EVENT_RIGHTTOLEFTLAYOUTCHANGED = new object(); - private static readonly object EVENT_DPI_CHANGED = new object(); + private static readonly object EVENT_ACTIVATED = new(); + private static readonly object EVENT_CLOSING = new(); + private static readonly object EVENT_CLOSED = new(); + private static readonly object EVENT_FORMCLOSING = new(); + private static readonly object EVENT_FORMCLOSED = new(); + private static readonly object EVENT_DEACTIVATE = new(); + private static readonly object EVENT_LOAD = new(); + private static readonly object EVENT_MDI_CHILD_ACTIVATE = new(); + private static readonly object EVENT_INPUTLANGCHANGE = new(); + private static readonly object EVENT_INPUTLANGCHANGEREQUEST = new(); + private static readonly object EVENT_MENUSTART = new(); + private static readonly object EVENT_MENUCOMPLETE = new(); + private static readonly object EVENT_MAXIMUMSIZECHANGED = new(); + private static readonly object EVENT_MINIMUMSIZECHANGED = new(); + private static readonly object EVENT_HELPBUTTONCLICKED = new(); + private static readonly object EVENT_SHOWN = new(); + private static readonly object EVENT_RESIZEBEGIN = new(); + private static readonly object EVENT_RESIZEEND = new(); + private static readonly object EVENT_RIGHTTOLEFTLAYOUTCHANGED = new(); + private static readonly object EVENT_DPI_CHANGED = new(); // // The following flags should be used with formState[..] not formStateEx[..] @@ -98,7 +98,7 @@ public partial class Form : ContainerControl private const int SizeGripSize = 16; private static Icon? defaultIcon; - private static readonly object internalSyncObject = new object(); + private static readonly object internalSyncObject = new(); // Property store keys for properties. The property store allocates most efficiently // in groups of four, so we try to lump properties in groups of four based on how @@ -135,21 +135,21 @@ public partial class Form : ContainerControl // Form per instance members // Note: Do not add anything to this list unless absolutely necessary. - private BitVector32 _formState = new BitVector32(0x21338); // magic value... all the defaults... see the ctor for details... + private BitVector32 _formState = new(0x21338); // magic value... all the defaults... see the ctor for details... private BitVector32 _formStateEx; private Icon? _icon; private Icon? _smallIcon; private Size _autoScaleBaseSize = Size.Empty; private Size _minAutoSize = Size.Empty; - private Rectangle _restoredWindowBounds = new Rectangle(-1, -1, -1, -1); + private Rectangle _restoredWindowBounds = new(-1, -1, -1, -1); private BoundsSpecified _restoredWindowBoundsSpecified; private DialogResult _dialogResult; private MdiClient? _ctlClient; private NativeWindow? _ownerWindow; private bool _rightToLeftLayout; - private Rectangle _restoreBounds = new Rectangle(-1, -1, -1, -1); + private Rectangle _restoreBounds = new(-1, -1, -1, -1); private CloseReason _closeReason = CloseReason.None; private VisualStyleRenderer? _sizeGripRenderer; @@ -1239,7 +1239,7 @@ protected Rectangle MaximizedBounds } } - private static readonly object EVENT_MAXIMIZEDBOUNDSCHANGED = new object(); + private static readonly object EVENT_MAXIMIZEDBOUNDSCHANGED = new(); [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.FormOnMaximizedBoundsChangedDescr))] @@ -3729,7 +3729,7 @@ protected void CenterToParent() return; } - Point p = default(Point); + Point p = default; Size s = Size; HWND ownerHandle = (HWND)PInvoke.GetWindowLong(this, WINDOW_LONG_PTR_INDEX.GWL_HWNDPARENT); @@ -3775,7 +3775,7 @@ protected void CenterToParent() /// protected void CenterToScreen() { - Point p = default(Point); + Point p = default; Screen desktop; if (OwnerInternal is not null) { @@ -4178,11 +4178,11 @@ protected override void OnVisibleChanged(EventArgs e) && data) { Control button = (Control)AcceptButton; - var ptToSnap = new Point(button.Left + button.Width / 2, button.Top + button.Height / 2); - PInvoke.ClientToScreen(this, ref ptToSnap); + Point pointToSnap = new(button.Left + button.Width / 2, button.Top + button.Height / 2); + PInvoke.ClientToScreen(this, ref pointToSnap); if (!button.IsWindowObscured) { - Cursor.Position = ptToSnap; + Cursor.Position = pointToSnap; } } } @@ -4231,7 +4231,7 @@ protected override void OnPaint(PaintEventArgs e) { _sizeGripRenderer ??= new VisualStyleRenderer(VisualStyleElement.Status.Gripper.Normal); - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); _sizeGripRenderer.DrawBackground( hdc, new Rectangle(size.Width - SizeGripSize, size.Height - SizeGripSize, SizeGripSize, SizeGripSize)); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormCollection.cs index 035bca1a365..e6b4e773ff3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/FormCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormCollection.cs @@ -12,7 +12,7 @@ namespace System.Windows.Forms; /// public class FormCollection : ReadOnlyCollectionBase { - internal static object CollectionSyncRoot = new object(); + internal static object CollectionSyncRoot = new(); /// /// Gets a form specified by name, if present, else returns null. If there are multiple diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Formatter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Formatter.cs index 7fce86008db..bb105792cdc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Formatter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Formatter.cs @@ -13,7 +13,7 @@ internal static class Formatter private static readonly Type stringType = typeof(string); private static readonly Type booleanType = typeof(bool); private static readonly Type checkStateType = typeof(CheckState); - private static readonly object parseMethodNotFound = new object(); + private static readonly object parseMethodNotFound = new(); private static readonly object defaultDataSourceNullValue = DBNull.Value; /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.cs index c2367c4fba1..a303bf677cf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBox.cs @@ -131,9 +131,9 @@ protected override CreateParams CreateParams } // Set the default Padding to 3 so that it is consistent with Everett - protected override Padding DefaultPadding => new Padding(3); + protected override Padding DefaultPadding => new(3); - protected override Size DefaultSize => new Size(200, 100); + protected override Size DefaultSize => new(200, 100); /// /// Gets a rectangle that represents the dimensions of the @@ -490,7 +490,7 @@ private void DrawGroupBox(PaintEventArgs e) } else { - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); DRAW_TEXT_FORMAT flags = DRAW_TEXT_FORMAT.DT_WORDBREAK | DRAW_TEXT_FORMAT.DT_EDITCONTROL; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBoxRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBoxRenderer.cs index 6eba2e32282..699b43e62f7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/GroupBoxRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/GroupBoxRenderer.cs @@ -315,7 +315,7 @@ private static void DrawUnthemedGroupBoxWithText( boxTop += font.Height / 2; } - using var hdc = new DeviceContextHdcScope(deviceContext); + using DeviceContextHdcScope hdc = new(deviceContext); ReadOnlySpan darkLines = stackalloc int[] { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HScrollBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HScrollBar.cs index 704b535c97f..49878f68061 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HScrollBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HScrollBar.cs @@ -22,5 +22,5 @@ protected override CreateParams CreateParams } protected override Size DefaultSize - => new Size(80, SystemInformation.HorizontalScrollBarHeight); + => new(80, SystemInformation.HorizontalScrollBarHeight); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Help.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Help.cs index df847c06401..481c99f010a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Help.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Help.cs @@ -14,7 +14,7 @@ namespace System.Windows.Forms; public static class Help { #if DEBUG - internal static readonly TraceSwitch WindowsFormsHelpTrace = new TraceSwitch("WindowsFormsHelpTrace", "Debug help system"); + internal static readonly TraceSwitch WindowsFormsHelpTrace = new("WindowsFormsHelpTrace", "Debug help system"); #else internal static readonly TraceSwitch? WindowsFormsHelpTrace; #endif @@ -96,7 +96,7 @@ public static unsafe void ShowPopup(Control? parent, string caption, Point locat { WindowsFormsHelpTrace.TraceVerbose("Help:: ShowPopup"); - var pop = new HH_POPUPW + HH_POPUPW pop = new() { cbStruct = sizeof(HH_POPUPW), pt = location, @@ -370,7 +370,7 @@ private static unsafe HH MapCommandToHTMLCommand(HelpNavigator command, string? case HelpNavigator.Find: { - var ftsQuery = new HH_FTS_QUERYW + HH_FTS_QUERYW ftsQuery = new() { cbStruct = sizeof(HH_FTS_QUERYW), iProximity = HH_FTS_QUERYW.DEFAULT_PROXIMITY, @@ -396,7 +396,7 @@ private static unsafe HH MapCommandToHTMLCommand(HelpNavigator command, string? case HelpNavigator.KeywordIndex: case HelpNavigator.AssociateIndex: { - var alink = new HH_ALINKW + HH_ALINKW alink = new() { cbStruct = sizeof(HH_ALINKW), fIndexOnFail = true, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventArgs.cs index 9877255cbf6..39c2826fff4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/HtmlElementEventArgs.cs @@ -49,17 +49,17 @@ public MouseButtons MouseButtonsPressed public Point ClientMousePosition { - get => new Point(NativeHTMLEventObj.GetClientX(), NativeHTMLEventObj.GetClientY()); + get => new(NativeHTMLEventObj.GetClientX(), NativeHTMLEventObj.GetClientY()); } public Point OffsetMousePosition { - get => new Point(NativeHTMLEventObj.GetOffsetX(), NativeHTMLEventObj.GetOffsetY()); + get => new(NativeHTMLEventObj.GetOffsetX(), NativeHTMLEventObj.GetOffsetY()); } public Point MousePosition { - get => new Point(NativeHTMLEventObj.GetX(), NativeHTMLEventObj.GetY()); + get => new(NativeHTMLEventObj.GetX(), NativeHTMLEventObj.GetY()); } public bool BubbleEvent diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs index ea1cdc5d4ce..293f975841f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs @@ -18,7 +18,7 @@ public sealed partial class ImageList public sealed partial class ImageCollection : IList { private readonly ImageList _owner; - private readonly List _imageInfoCollection = new List(); + private readonly List _imageInfoCollection = new(); /// A caching mechanism for key accessor /// We use an index here rather than control so that we don't have lifetime @@ -235,13 +235,13 @@ public void Add(string key, Image image) Debug.Assert((Count == _imageInfoCollection.Count), "The count of these two collections should be equal."); // Store off the name. - var imageInfo = new ImageInfo + ImageInfo imageInfo = new() { Name = key }; // Add the image to the IList - var original = new Original(image, OriginalOptions.Default); + Original original = new(image, OriginalOptions.Default); Add(original, imageInfo); } @@ -253,13 +253,13 @@ public void Add(string key, Icon icon) Debug.Assert((Count == _imageInfoCollection.Count), "The count of these two collections should be equal."); // Store off the name. - var imageInfo = new ImageInfo + ImageInfo imageInfo = new() { Name = key }; // Add the image to the IList - var original = new Original(icon, OriginalOptions.Default); + Original original = new(icon, OriginalOptions.Default); Add(original, imageInfo); } @@ -289,7 +289,7 @@ public void Add(Image value) { ArgumentNullException.ThrowIfNull(value); - var original = new Original(value, OriginalOptions.Default); + Original original = new(value, OriginalOptions.Default); Add(original, null); } @@ -302,7 +302,7 @@ public int Add(Image value, Color transparentColor) { ArgumentNullException.ThrowIfNull(value); - var original = new Original(value, OriginalOptions.CustomTransparentColor, transparentColor); + Original original = new(value, OriginalOptions.CustomTransparentColor, transparentColor); return Add(original, null); } @@ -409,7 +409,7 @@ public int AddStrip(Image value) int nImages = value.Width / _owner.ImageSize.Width; - var original = new Original(value, OriginalOptions.ImageStrip, nImages); + Original original = new(value, OriginalOptions.ImageStrip, nImages); return Add(original, null); } @@ -437,7 +437,7 @@ public void Clear() bool IList.Contains(object? value) { - if (!(value is Image image)) + if (value is not Image image) { return false; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.NativeImageList.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.NativeImageList.cs index d503c9858d1..5b7d2d75f1f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.NativeImageList.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.NativeImageList.cs @@ -17,7 +17,7 @@ internal class NativeImageList : IDisposable, IHandle private const int GrowBy = 4; private const int InitialCapacity = 4; - private static readonly object s_syncLock = new object(); + private static readonly object s_syncLock = new(); public unsafe NativeImageList(IStream.Interface pstm) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs index b0a8d1cb637..9b159ae530a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs @@ -26,7 +26,7 @@ namespace System.Windows.Forms; public sealed partial class ImageList : Component, IHandle { private static readonly Color s_fakeTransparencyColor = Color.FromArgb(0x0d, 0x0b, 0x0c); - private static readonly Size s_defaultImageSize = new Size(16, 16); + private static readonly Size s_defaultImageSize = new(16, 16); private const int MaxDimension = 256; private static int s_maxImageWidth = MaxDimension; @@ -44,7 +44,7 @@ public sealed partial class ImageList : Component, IHandle // lists are lossy. At runtime, we delay handle creation as long as possible, and store // away the original images until handle creation (and hope no one disposes of the images!). At design time, we keep the originals around indefinitely. // This variable will become null when the original images are lost. - private List? _originals = new List(); + private List? _originals = new(); private EventHandler? _recreateHandler; private EventHandler? _changeHandler; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ImageListStreamer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ImageListStreamer.cs index eb4c6cdc6e3..3aa99d88ac9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ImageListStreamer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ImageListStreamer.cs @@ -12,7 +12,7 @@ public sealed class ImageListStreamer : ISerializable, IDisposable { // Compressed magic header. If we see this, the image stream is compressed. private static ReadOnlySpan HeaderMagic => "MSFt"u8; - private static readonly object s_syncObject = new object(); + private static readonly object s_syncObject = new(); private readonly ImageList? _imageList; private ImageList.NativeImageList? _nativeImageList; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguage.cs b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguage.cs index 8f92db7d831..e5644b3cf3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguage.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/InputLanguage.cs @@ -27,7 +27,7 @@ internal InputLanguage(IntPtr handle) /// /// Returns the culture of the current input language. /// - public CultureInfo Culture => new CultureInfo(LanguageTag); + public CultureInfo Culture => new(LanguageTag); /// /// Gets or sets the input language for the current thread. @@ -236,7 +236,7 @@ internal static InputLanguageChangedEventArgs CreateInputLanguageChangedEventArg /// internal static InputLanguageChangingEventArgs CreateInputLanguageChangingEventArgs(Message m) { - var inputLanguage = new InputLanguage(m.LParamInternal); + InputLanguage inputLanguage = new(m.LParamInternal); // NOTE: by default we should allow any locale switch bool localeSupportedBySystem = m.WParamInternal != 0u; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.cs index d6c0be0f057..941448c67fe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/FontCache.cs @@ -22,7 +22,7 @@ namespace System.Windows.Forms; /// internal sealed partial class FontCache : RefCountedCache { - private readonly object _lock = new object(); + private readonly object _lock = new(); /// /// Create a with the specified collection limits. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.cs index 74d1f22a123..b845f4d5741 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Internal/Gdi/GdiCache.cs @@ -14,7 +14,7 @@ internal static partial class GdiCache [ThreadStatic] private static ScreenDcCache? s_dcCache; - private static readonly FontCache s_fontCache = new FontCache(); + private static readonly FontCache s_fontCache = new(); /// /// Gets an based off of the primary display. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/KeysConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/KeysConverter.cs index 019500d6e16..fee2bfc9dd2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/KeysConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/KeysConverter.cs @@ -35,8 +35,8 @@ private void AddLocalizedKeyNames(CultureInfo cultureInfo) return; } - var localizedOrder = new List(34); - var localizedNames = new Dictionary(34); + List localizedOrder = new(34); + Dictionary localizedNames = new(34); AddLocalizedKey(nameof(SR.toStringEnter), Keys.Return); AddKey("F12", Keys.F12); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Label.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Label.cs index dbe5456d69b..b85c178f480 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Label.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Label.cs @@ -305,13 +305,13 @@ protected override CreateParams CreateParams protected override ImeMode DefaultImeMode => ImeMode.Disable; - protected override Padding DefaultMargin => new Padding(3, 0, 3, 0); + protected override Padding DefaultMargin => new(3, 0, 3, 0); /// /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. /// - protected override Size DefaultSize => new Size(100, AutoSize ? PreferredHeight : 23); + protected override Size DefaultSize => new(100, AutoSize ? PreferredHeight : 23); [SRCategory(nameof(SR.CatAppearance))] [DefaultValue(FlatStyle.Standard)] @@ -1280,7 +1280,7 @@ protected override void OnPaint(PaintEventArgs e) } Color color; - using (var hdc = new DeviceContextHdcScope(e)) + using (DeviceContextHdcScope hdc = new(e)) { color = hdc.FindNearestColor(Enabled ? ForeColor : DisabledColor); } @@ -1373,7 +1373,7 @@ private protected override void PrintToMetaFileRecursive(HDC hDC, IntPtr lParam, { base.PrintToMetaFileRecursive(hDC, lParam, bounds); - using var mapping = new DCMapping(hDC, bounds); + using DCMapping mapping = new(hDC, bounds); using Graphics g = hDC.CreateGraphics(); ControlPaint.PrintBorder(g, new Rectangle(Point.Empty, Size), BorderStyle, Border3DStyle.SunkenOuter); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs index 5eca446eedc..99181a05833 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/ArrangedElementCollection.cs @@ -8,7 +8,7 @@ namespace System.Windows.Forms.Layout; public class ArrangedElementCollection : IList { - internal static ArrangedElementCollection Empty = new ArrangedElementCollection(0); + internal static ArrangedElementCollection Empty = new(0); internal ArrangedElementCollection() : this(4) @@ -49,7 +49,7 @@ public override bool Equals(object? obj) public override int GetHashCode() { - var hash = default(HashCode); + HashCode hash = default; foreach (object o in InnerList) { hash.Add(o); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs index b2daddb5f22..4e67ed59bc5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/CommonProperties.cs @@ -38,9 +38,9 @@ internal partial class CommonProperties internal const bool DefaultAutoSize = false; internal const DockStyle DefaultDock = DockStyle.None; - internal static readonly Padding DefaultMargin = new Padding(3); - internal static readonly Size DefaultMinimumSize = new Size(0, 0); - internal static readonly Size DefaultMaximumSize = new Size(0, 0); + internal static readonly Padding DefaultMargin = new(3); + internal static readonly Size DefaultMinimumSize = new(0, 0); + internal static readonly Size DefaultMaximumSize = new(0, 0); // DO NOT MOVE THE FOLLOWING 4 SECTIONS // We have done some special arranging here so that if the first 7 bits of state are zero, we know @@ -721,7 +721,7 @@ internal static void SetLayoutState(IArrangedElement element, BitVector32 state) #region DebugHelpers #if DEBUG - internal static readonly TraceSwitch PreferredSize = new TraceSwitch("PreferredSize", "Debug preferred size assertion"); + internal static readonly TraceSwitch PreferredSize = new("PreferredSize", "Debug preferred size assertion"); internal static string Debug_GetChangedProperties(IArrangedElement element) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs index 83de206c8f8..3ac34da0a3c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/DefaultLayout.cs @@ -15,7 +15,7 @@ namespace System.Windows.Forms.Layout; internal partial class DefaultLayout : LayoutEngine { - internal static readonly DefaultLayout Instance = new DefaultLayout(); + internal static readonly DefaultLayout Instance = new(); private static readonly int s_layoutInfoProperty = PropertyStore.CreateKey(); private static readonly int s_cachedBoundsProperty = PropertyStore.CreateKey(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.cs index 1ff3aec92ee..bf7cf708cec 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/FlowLayout.cs @@ -13,7 +13,7 @@ namespace System.Windows.Forms.Layout; internal partial class FlowLayout : LayoutEngine { - internal static readonly FlowLayout Instance = new FlowLayout(); + internal static readonly FlowLayout Instance = new(); private static readonly int s_wrapContentsProperty = PropertyStore.CreateKey(); private static readonly int s_flowDirectionProperty = PropertyStore.CreateKey(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ColumnSpanComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ColumnSpanComparer.cs index 2fa14a0eb65..69013ef02cd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ColumnSpanComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.ColumnSpanComparer.cs @@ -8,7 +8,7 @@ internal partial class TableLayout { private class ColumnSpanComparer : SpanComparer { - private static readonly ColumnSpanComparer instance = new ColumnSpanComparer(); + private static readonly ColumnSpanComparer instance = new(); public override int GetSpan(LayoutInfo layoutInfo) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.LayoutInfo.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.LayoutInfo.cs index 7d3213f5ab7..619a33ac6e2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.LayoutInfo.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.LayoutInfo.cs @@ -45,7 +45,7 @@ public LayoutInfo(IArrangedElement element) public int RowSpan { get; set; } = 1; #if DEBUG - public LayoutInfo Clone() => new LayoutInfo(Element) + public LayoutInfo Clone() => new(Element) { RowStart = RowStart, ColumnStart = ColumnStart, @@ -69,7 +69,7 @@ public override bool Equals(object? obj) public override int GetHashCode() { - var hash = default(HashCode); + HashCode hash = default; hash.Add(RowStart); hash.Add(ColumnStart); hash.Add(RowSpan); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MaxSizeProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MaxSizeProxy.cs index 926ffba1f16..1c21f412048 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MaxSizeProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MaxSizeProxy.cs @@ -8,7 +8,7 @@ internal partial class TableLayout { private class MaxSizeProxy : SizeProxy { - private static readonly MaxSizeProxy instance = new MaxSizeProxy(); + private static readonly MaxSizeProxy instance = new(); public override int Size { get { return strip.MaxSize; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MinSizeProxy.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MinSizeProxy.cs index d1718583a91..5932cfd0f6a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MinSizeProxy.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.MinSizeProxy.cs @@ -8,7 +8,7 @@ internal partial class TableLayout { private class MinSizeProxy : SizeProxy { - private static readonly MinSizeProxy instance = new MinSizeProxy(); + private static readonly MinSizeProxy instance = new(); public override int Size { get { return strip.MinSize; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PostAssignedPositionComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PostAssignedPositionComparer.cs index 76debff60c5..38b3d261e93 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PostAssignedPositionComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PostAssignedPositionComparer.cs @@ -8,7 +8,7 @@ internal partial class TableLayout { private class PostAssignedPositionComparer : IComparer { - private static readonly PostAssignedPositionComparer instance = new PostAssignedPositionComparer(); + private static readonly PostAssignedPositionComparer instance = new(); public static PostAssignedPositionComparer GetInstance { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PreAssignedPositionComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PreAssignedPositionComparer.cs index 580bbb66814..b94d3b2dbb2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PreAssignedPositionComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.PreAssignedPositionComparer.cs @@ -8,7 +8,7 @@ internal partial class TableLayout { private class PreAssignedPositionComparer : IComparer { - private static readonly PreAssignedPositionComparer instance = new PreAssignedPositionComparer(); + private static readonly PreAssignedPositionComparer instance = new(); public static PreAssignedPositionComparer GetInstance { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.RowSpanComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.RowSpanComparer.cs index 6fd08124005..423b37f23dd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.RowSpanComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.RowSpanComparer.cs @@ -8,7 +8,7 @@ internal partial class TableLayout { private class RowSpanComparer : SpanComparer { - private static readonly RowSpanComparer instance = new RowSpanComparer(); + private static readonly RowSpanComparer instance = new(); public override int GetSpan(LayoutInfo layoutInfo) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.cs index 637f00fd829..6558a781a92 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Layout/TableLayout.cs @@ -38,7 +38,7 @@ private static void Sort(LayoutInfo[] array, IComparer comparer) // End of sorting code // Singleton instance shared by all containers. - internal static readonly TableLayout Instance = new TableLayout(); + internal static readonly TableLayout Instance = new(); private static readonly int _containerInfoProperty = PropertyStore.CreateKey(); private static readonly int _layoutInfoProperty = PropertyStore.CreateKey(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.cs index 1b671607b0d..7dc9a569824 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/LinkLabel.cs @@ -20,10 +20,10 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionLinkLabel))] public partial class LinkLabel : Label, IButtonControl { - private static readonly object s_eventLinkClicked = new object(); + private static readonly object s_eventLinkClicked = new(); private static Color s_iedisabledLinkColor = Color.Empty; - private static readonly LinkComparer s_linkComparer = new LinkComparer(); + private static readonly LinkComparer s_linkComparer = new(); private DialogResult _dialogResult; @@ -37,7 +37,7 @@ public partial class LinkLabel : Label, IButtonControl private bool _textLayoutValid; private bool _receivedDoubleClick; - private readonly List _links = new List(2); + private readonly List _links = new(2); private Link? _focusLink; private LinkCollection? _linkCollection; @@ -1120,7 +1120,7 @@ protected override void OnPaint(PaintEventArgs e) else { Color foreColor; - using (var scope = new DeviceContextHdcScope(e, applyGraphicsState: false)) + using (DeviceContextHdcScope scope = new(e, applyGraphicsState: false)) { foreColor = scope.HDC.FindNearestColor(DisabledColor); } @@ -1370,7 +1370,7 @@ private void PaintLink( else { Color color; - using (var hdc = new DeviceContextHdcScope(g, applyGraphicsState: false)) + using (DeviceContextHdcScope hdc = new(g, applyGraphicsState: false)) { color = ColorTranslator.FromWin32( (int)PInvoke.GetNearestColor(hdc, (COLORREF)(uint)ColorTranslator.ToWin32(foreBrush.Color)).Value); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.cs index 02b1acbef78..599ac84aa53 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListBox.cs @@ -36,9 +36,9 @@ public partial class ListBox : ListControl /// public const int DefaultItemHeight = 13; - private static readonly object EVENT_SELECTEDINDEXCHANGED = new object(); - private static readonly object EVENT_DRAWITEM = new object(); - private static readonly object EVENT_MEASUREITEM = new object(); + private static readonly object EVENT_SELECTEDINDEXCHANGED = new(); + private static readonly object EVENT_DRAWITEM = new(); + private static readonly object EVENT_MEASUREITEM = new(); private SelectedObjectCollection? _selectedItems; private SelectedIndexCollection? _selectedIndices; @@ -1459,7 +1459,7 @@ public int GetItemHeight(int index) public Rectangle GetItemRectangle(int index) { CheckIndex(index); - var rect = default(RECT); + RECT rect = default; if (PInvoke.SendMessage(this, PInvoke.LB_GETITEMRECT, (uint)index, ref rect) == 0) { return Rectangle.Empty; @@ -2382,7 +2382,7 @@ private unsafe void WmReflectDrawItem(ref Message m) bounds.Width = MultiColumn ? Math.Max(ColumnWidth, bounds.Width) : Math.Max(MaxItemWidth, bounds.Width); } - using var e = new DrawItemEventArgs( + using DrawItemEventArgs e = new( dis->hDC, Font, bounds, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListControl.cs index c3a903bab05..dd01b579f80 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListControl.cs @@ -12,14 +12,14 @@ namespace System.Windows.Forms; [LookupBindingProperties(nameof(DataSource), nameof(DisplayMember), nameof(ValueMember), nameof(SelectedValue))] public abstract class ListControl : Control { - private static readonly object s_dataSourceChangedEvent = new object(); - private static readonly object s_displayMemberChangedEvent = new object(); - private static readonly object s_valueMemberChangedEvent = new object(); - private static readonly object s_selectedValueChangedEvent = new object(); - private static readonly object s_formatInfoChangedEvent = new object(); - private static readonly object s_formatStringChangedEvent = new object(); - private static readonly object s_formattingEnabledChangedEvent = new object(); - private static readonly object s_formatEvent = new object(); + private static readonly object s_dataSourceChangedEvent = new(); + private static readonly object s_displayMemberChangedEvent = new(); + private static readonly object s_valueMemberChangedEvent = new(); + private static readonly object s_selectedValueChangedEvent = new(); + private static readonly object s_formatInfoChangedEvent = new(); + private static readonly object s_formatStringChangedEvent = new(); + private static readonly object s_formattingEnabledChangedEvent = new(); + private static readonly object s_formatEvent = new(); private object? _dataSource; private CurrencyManager? _dataManager; @@ -519,7 +519,7 @@ private protected int FindStringInternal(string? str, IList? items, int startInd object? filteredItem = FilterItemOnProperty(item, _displayMember.BindingField); // First try the OnFormat event - var e = new ListControlConvertEventArgs(filteredItem, typeof(string), item); + ListControlConvertEventArgs e = new(filteredItem, typeof(string), item); OnFormat(e); if (e.Value != item && e.Value is string stringValue) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewNativeItemCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewNativeItemCollection.cs index eb1390a6116..7c2cf06df4a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewNativeItemCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewNativeItemCollection.cs @@ -190,7 +190,7 @@ private int DisplayIndexToID(int displayIndex) if (_owner.IsHandleCreated && !_owner.ListViewHandleDestroyed) { // Obtain internal index of the item - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_PARAM, iItem = displayIndex diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs index 804f8be834a..9d8886c5224 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs @@ -30,21 +30,21 @@ public partial class ListView : Control { private const int MASK_HITTESTFLAG = 0x00F7; - private static readonly object EVENT_CACHEVIRTUALITEMS = new object(); - private static readonly object EVENT_COLUMNREORDERED = new object(); - private static readonly object EVENT_COLUMNWIDTHCHANGED = new object(); - private static readonly object EVENT_COLUMNWIDTHCHANGING = new object(); - private static readonly object EVENT_DRAWCOLUMNHEADER = new object(); - private static readonly object EVENT_DRAWITEM = new object(); - private static readonly object EVENT_DRAWSUBITEM = new object(); - private static readonly object EVENT_ITEMSELECTIONCHANGED = new object(); - private static readonly object EVENT_RETRIEVEVIRTUALITEM = new object(); - private static readonly object EVENT_SEARCHFORVIRTUALITEM = new object(); - private static readonly object EVENT_SELECTEDINDEXCHANGED = new object(); - private static readonly object EVENT_VIRTUALITEMSSELECTIONRANGECHANGED = new object(); - private static readonly object EVENT_RIGHTTOLEFTLAYOUTCHANGED = new object(); - private static readonly object EVENT_GROUPCOLLAPSEDSTATECHANGED = new object(); - private static readonly object EVENT_GROUPTASKLINKCLICK = new object(); + private static readonly object EVENT_CACHEVIRTUALITEMS = new(); + private static readonly object EVENT_COLUMNREORDERED = new(); + private static readonly object EVENT_COLUMNWIDTHCHANGED = new(); + private static readonly object EVENT_COLUMNWIDTHCHANGING = new(); + private static readonly object EVENT_DRAWCOLUMNHEADER = new(); + private static readonly object EVENT_DRAWITEM = new(); + private static readonly object EVENT_DRAWSUBITEM = new(); + private static readonly object EVENT_ITEMSELECTIONCHANGED = new(); + private static readonly object EVENT_RETRIEVEVIRTUALITEM = new(); + private static readonly object EVENT_SEARCHFORVIRTUALITEM = new(); + private static readonly object EVENT_SELECTEDINDEXCHANGED = new(); + private static readonly object EVENT_VIRTUALITEMSSELECTIONRANGECHANGED = new(); + private static readonly object EVENT_RIGHTTOLEFTLAYOUTCHANGED = new(); + private static readonly object EVENT_GROUPCOLLAPSEDSTATECHANGED = new(); + private static readonly object EVENT_GROUPTASKLINKCLICK = new(); private ItemActivation _activation = ItemActivation.Standard; private ListViewAlignment _alignStyle = ListViewAlignment.Top; @@ -398,7 +398,7 @@ public unsafe bool BackgroundImageTiled // We don't need to delete it and this causes BAD problems w/ the Win32 list view control. fixed (char* pBackgroundImageFileName = _backgroundImageFileName) { - var lvbkImage = default(LVBKIMAGEW); + LVBKIMAGEW lvbkImage = default; if (BackgroundImageTiled) { lvbkImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_TILE; @@ -1679,7 +1679,7 @@ public unsafe Size TileSize return Size.Empty; } - var tileViewInfo = new LVTILEVIEWINFO + LVTILEVIEWINFO tileViewInfo = new() { cbSize = (uint)sizeof(LVTILEVIEWINFO), dwMask = LVTILEVIEWINFO_MASK.LVTVIM_TILESIZE @@ -1707,7 +1707,7 @@ public unsafe Size TileSize return; } - var tileViewInfo = new LVTILEVIEWINFO + LVTILEVIEWINFO tileViewInfo = new() { cbSize = (uint)sizeof(LVTILEVIEWINFO), dwMask = LVTILEVIEWINFO_MASK.LVTVIM_TILESIZE, @@ -3362,7 +3362,7 @@ public void EnsureVisible(int index) { fixed (char* pText = text) { - var lvFindInfo = default(LVFINDINFOW); + LVFINDINFOW lvFindInfo = default; if (isTextSearch) { lvFindInfo.flags = LVFINDINFOW_FLAGS.LVFI_STRING; @@ -3475,9 +3475,9 @@ internal int GetDisplayIndex(ListViewItem item, int lastIndex) ApplyUpdateCachedItems(); if (IsHandleCreated && !ListViewHandleDestroyed) { - var info = new LVFINDINFOW + LVFINDINFOW info = new() { - lParam = (IntPtr)item.ID, + lParam = item.ID, flags = LVFINDINFOW_FLAGS.LVFI_PARAM }; @@ -3545,7 +3545,7 @@ internal int GetColumnIndex(ColumnHeader ch) /// public ListViewItem? GetItemAt(int x, int y) { - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = new Point(x, y) }; @@ -3585,7 +3585,7 @@ internal override unsafe ComCtl32.ToolInfoWrapper GetToolInfoWrapper(TO // The second condition is necessary for the correct display of the keyboard tooltip, // since the logic of the external tooltip blocks its display bool isExternalTooltip = ShowItemToolTips && tooltip != KeyboardToolTip; - var wrapper = new ComCtl32.ToolInfoWrapper(this, flags, isExternalTooltip ? null : caption); + ComCtl32.ToolInfoWrapper wrapper = new(this, flags, isExternalTooltip ? null : caption); if (isExternalTooltip) wrapper.Info.lpszText = (char*)(-1); @@ -3594,7 +3594,7 @@ internal override unsafe ComCtl32.ToolInfoWrapper GetToolInfoWrapper(TO internal void GetSubItemAt(int x, int y, out int iItem, out int iSubItem) { - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = new Point(x, y) }; @@ -3614,9 +3614,9 @@ internal void GetSubItemAt(int x, int y, out int iItem, out int iSubItem) internal Point GetItemPosition(int index) { - var pt = default(Point); - PInvoke.SendMessage(this, PInvoke.LVM_GETITEMPOSITION, (WPARAM)index, ref pt); - return pt; + Point position = default; + PInvoke.SendMessage(this, PInvoke.LVM_GETITEMPOSITION, (WPARAM)index, ref position); + return position; } internal LIST_VIEW_ITEM_STATE_FLAGS GetItemState(int index) @@ -3660,7 +3660,7 @@ public Rectangle GetItemRect(int index, ItemBoundsPortion portion) return Rectangle.Empty; } - var itemrect = new RECT + RECT itemrect = new() { left = (int)portion }; @@ -3692,7 +3692,7 @@ private Rectangle GetItemRectOrEmpty(int index) return Rectangle.Empty; } - var itemrect = new RECT + RECT itemrect = new() { left = 0 }; @@ -3742,7 +3742,7 @@ internal Rectangle GetSubItemRect(int itemIndex, int subItemIndex, ItemBoundsPor return Rectangle.Empty; } - var itemrect = new RECT + RECT itemrect = new() { left = (int)portion, top = subItemIndex @@ -3791,7 +3791,7 @@ public ListViewHitTestInfo HitTest(int x, int y) return new ListViewHitTestInfo(hitItem: null, hitSubItem: null, hitLocation: ListViewHitTestLocations.None); } - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = new Point(x, y) }; @@ -3984,7 +3984,7 @@ internal ColumnHeader InsertColumn(int index, ColumnHeader ch, bool refreshSubIt private unsafe int InsertColumnNative(int index, ColumnHeader ch) { - var lvColumn = new LVCOLUMNW + LVCOLUMNW lvColumn = new() { mask = LVCOLUMNW_MASK.LVCF_FMT | LVCOLUMNW_MASK.LVCF_TEXT | LVCOLUMNW_MASK.LVCF_WIDTH }; @@ -4041,7 +4041,7 @@ internal void InsertGroupInListView(int index, ListViewGroup group) for (int i = 0; i < Items.Count; i++) { ListViewItem item = Items[i]; - var lvItem = new LVITEMW + LVITEMW lvItem = new() { iItem = item.Index, mask = LIST_VIEW_ITEM_FLAGS.LVIF_GROUPID @@ -4199,7 +4199,7 @@ private unsafe int InsertItemsNative(int index, ListViewItem[] items) Debug.Assert(Items.Contains(li), "Make sure ListView.Items contains this item before adding the native LVITEM. Otherwise, custom-drawing may break."); - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_TEXT | LIST_VIEW_ITEM_FLAGS.LVIF_IMAGE | LIST_VIEW_ITEM_FLAGS.LVIF_PARAM | LIST_VIEW_ITEM_FLAGS.LVIF_INDENT | @@ -4207,7 +4207,7 @@ private unsafe int InsertItemsNative(int index, ListViewItem[] items) iItem = index + i, iImage = li.ImageIndexer.ActualIndex, iIndent = li.IndentCount, - lParam = (IntPtr)li.ID, + lParam = li.ID, cColumns = _columnHeaders is not null ? Math.Min(MAXTILECOLUMNS, _columnHeaders.Length) : 0, }; @@ -4989,13 +4989,13 @@ private unsafe void PositionHeader() private void RealizeAllSubItems() { - var lvItem = default(LVITEMW); + LVITEMW item = default; for (int i = 0; i < _itemCount; i++) { int subItemCount = Items[i].SubItems.Count; for (int j = 0; j < subItemCount; j++) { - SetItemText(i, j, Items[i].SubItems[j].Text, ref lvItem); + SetItemText(i, j, Items[i].SubItems[j].Text, ref item); } } } @@ -5197,7 +5197,7 @@ private unsafe void SetBackgroundImage() // needed for OleInitialize Application.OleRequired(); - var lvbkImage = default(LVBKIMAGEW); + LVBKIMAGEW backgroundImage = default; // first, is there an existing temporary file to delete, remember its name // so that we can delete it if the list control doesn't... @@ -5210,27 +5210,27 @@ private unsafe void SetBackgroundImage() BackgroundImage.Save(_backgroundImageFileName, System.Drawing.Imaging.ImageFormat.Bmp); - lvbkImage.cchImageMax = (uint)(_backgroundImageFileName.Length + 1); - lvbkImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_SOURCE_URL; + backgroundImage.cchImageMax = (uint)(_backgroundImageFileName.Length + 1); + backgroundImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_SOURCE_URL; if (BackgroundImageTiled) { - lvbkImage.ulFlags |= LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_TILE; + backgroundImage.ulFlags |= LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_TILE; } else { - lvbkImage.ulFlags |= LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_NORMAL; + backgroundImage.ulFlags |= LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_STYLE_NORMAL; } } else { - lvbkImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_SOURCE_NONE; + backgroundImage.ulFlags = LIST_VIEW_BACKGROUND_IMAGE_FLAGS.LVBKIF_SOURCE_NONE; _backgroundImageFileName = string.Empty; } fixed (char* pBackgroundImageFileName = _backgroundImageFileName) { - lvbkImage.pszImage = pBackgroundImageFileName; - PInvoke.SendMessage(this, PInvoke.LVM_SETBKIMAGEW, (WPARAM)0, ref lvbkImage); + backgroundImage.pszImage = pBackgroundImageFileName; + PInvoke.SendMessage(this, PInvoke.LVM_SETBKIMAGEW, (WPARAM)0, ref backgroundImage); } if (string.IsNullOrEmpty(fileNameToDelete)) @@ -5470,7 +5470,7 @@ internal void SetItemImage(int itemIndex, int imageIndex) return; } - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_IMAGE, iItem = itemIndex, @@ -5492,7 +5492,7 @@ internal void SetItemIndentCount(int index, int indentCount) return; } - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_INDENT, iItem = index, @@ -5516,7 +5516,7 @@ internal void SetItemPosition(int index, int x, int y) Debug.Assert(IsHandleCreated, "How did we add items without a handle?"); - var pt = new Point(x, y); + Point pt = new(x, y); PInvoke.SendMessage(this, PInvoke.LVM_SETITEMPOSITION32, (WPARAM)index, ref pt); } @@ -5532,7 +5532,7 @@ internal void SetItemState(int index, LIST_VIEW_ITEM_STATE_FLAGS state, LIST_VIE return; } - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_STATE, state = state, @@ -5544,7 +5544,7 @@ internal void SetItemState(int index, LIST_VIEW_ITEM_STATE_FLAGS state, LIST_VIE internal void SetItemText(int itemIndex, int subItemIndex, string text) { - var lvItem = default(LVITEMW); + LVITEMW lvItem = default; SetItemText(itemIndex, subItemIndex, text, ref lvItem); } @@ -5778,7 +5778,7 @@ private unsafe nint SendGroupMessage(ListViewGroup group, uint msg, nint lParam, string footer = group.Footer; string subtitle = group.Subtitle; string task = group.TaskLink; - var lvgroup = new LVGROUPW + LVGROUPW lvgroup = new() { cbSize = (uint)sizeof(LVGROUPW), mask = LVGF.HEADER | LVGF.ALIGN | LVGF.STATE | LVGF.TITLEIMAGE | additionalMask, @@ -5885,7 +5885,7 @@ private unsafe void UpdateTileView() Debug.Assert(Application.ComCtlSupportsVisualStyles, "this function works only when ComCtl 6.0 and higher is loaded"); Debug.Assert(_viewStyle == View.Tile, "this function should be called only in Tile view"); - var tileViewInfo = new LVTILEVIEWINFO + LVTILEVIEWINFO tileViewInfo = new() { cbSize = (uint)sizeof(LVTILEVIEWINFO), @@ -5909,7 +5909,7 @@ private void WmNmClick() return; } - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = PointToClient(Cursor.Position) }; @@ -5951,7 +5951,7 @@ private void WmNmDblClick() return; } - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = PointToClient(Cursor.Position) }; @@ -6057,7 +6057,7 @@ private unsafe bool WmNotify(ref Message m) Color foreColor = Color.FromArgb((int)PInvoke.GetTextColor(nmcd->hdc).Value); Color backColor = Color.FromArgb((int)PInvoke.GetBkColor(nmcd->hdc).Value); Font font = GetListHeaderFont(); - var e = new DrawListViewColumnHeaderEventArgs( + DrawListViewColumnHeaderEventArgs e = new( g, nmcd->rc, (int)nmcd->dwItemSpec, @@ -6389,7 +6389,7 @@ private int GetIndexOfClickedItem() private LVHITTESTINFO SetupHitTestInfo() { - var lvhi = new LVHITTESTINFO + LVHITTESTINFO lvhi = new() { pt = PointToClient(Cursor.Position) }; @@ -6937,10 +6937,10 @@ private unsafe void WmReflectNotify(ref Message m) startIndex = 0; } - var sviEvent = new SearchForVirtualItemEventArgs( + SearchForVirtualItemEventArgs sviEvent = new( isTextSearch, isPrefixSearch, - false, /* includeSubItemsInSearch */ + includeSubItemsInSearch: false, text, startingPoint, dir, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObject.cs index 3446af94e31..4040919eab6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObject.cs @@ -56,7 +56,7 @@ public override Rectangle Bounds : PInvoke.LVGGR_GROUP; // Get the native rectangle - RECT groupRect = default(RECT); + RECT groupRect = default; // Using the "top" property, we set which rectangle type of the group we want to get // This is described in more detail in https://docs.microsoft.com/windows/win32/controls/lvm-getgrouprect diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupConverter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupConverter.cs index 4bf461ffb7b..a66a703c842 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupConverter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroupConverter.cs @@ -118,7 +118,7 @@ public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destina { if (context is not null && context.Instance is ListViewItem item && item.ListView is not null) { - var list = new ArrayList(); + ArrayList list = new(); foreach (ListViewGroup group in item.ListView.Groups) { list.Add(group); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewInsertionMark.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewInsertionMark.cs index 18881634045..b6dedc3786d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewInsertionMark.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewInsertionMark.cs @@ -55,9 +55,9 @@ public Rectangle Bounds { get { - var rect = default(RECT); - PInvoke.SendMessage(_listView, PInvoke.LVM_GETINSERTMARKRECT, (WPARAM)0, ref rect); - return rect; + RECT bounds = default; + PInvoke.SendMessage(_listView, PInvoke.LVM_GETINSERTMARKRECT, (WPARAM)0, ref bounds); + return bounds; } } @@ -115,7 +115,7 @@ public int Index /// public unsafe int NearestIndex(Point pt) { - var lvInsertMark = new LVINSERTMARK + LVINSERTMARK lvInsertMark = new() { cbSize = (uint)sizeof(LVINSERTMARK) }; @@ -128,7 +128,7 @@ public unsafe int NearestIndex(Point pt) internal unsafe void UpdateListView() { Debug.Assert(_listView.IsHandleCreated, "ApplySavedState Precondition: List-view handle must be created"); - var lvInsertMark = new LVINSERTMARK + LVINSERTMARK lvInsertMark = new() { cbSize = (uint)sizeof(LVINSERTMARK), dwFlags = _appearsAfterItem ? LVIM.AFTER : LVIM.BEFORE, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.cs index e73143fb75b..f0c22634360 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.cs @@ -32,7 +32,7 @@ public partial class ListViewItem : ICloneable, ISerializable private static readonly BitVector32.Section s_subItemCountSection = BitVector32.CreateSection(MaxSubItems, s_savedStateImageIndexSection); private int _indentCount; - private Point _position = new Point(-1, -1); + private Point _position = new(-1, -1); internal ListView? _listView; @@ -315,7 +315,7 @@ public Rectangle Bounds } else { - return default(Rectangle); + return default; } } } @@ -979,7 +979,7 @@ public Rectangle GetBounds(ItemBoundsPortion portion) return _listView.GetItemRect(Index, portion); } - return default(Rectangle); + return default; } public ListViewSubItem? GetSubItemAt(int x, int y) @@ -1058,8 +1058,8 @@ internal void UpdateGroupFromName() internal void UpdateStateToListView(int index) { - var lvItem = default(LVITEMW); - UpdateStateToListView(index, ref lvItem, true); + LVITEMW item = default; + UpdateStateToListView(index, ref item, updateOwner: true); } /// @@ -1122,7 +1122,7 @@ internal void UpdateStateFromListView(int displayIndex, bool checkSelection) if (_listView is not null && _listView.IsHandleCreated && displayIndex != -1) { // Get information from comctl control - var lvItem = new LVITEMW + LVITEMW lvItem = new() { mask = LIST_VIEW_ITEM_FLAGS.LVIF_PARAM | LIST_VIEW_ITEM_FLAGS.LVIF_STATE | LIST_VIEW_ITEM_FLAGS.LVIF_GROUPID }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditUiaTextProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditUiaTextProvider.cs index 831e26aab02..1986b91bc6b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditUiaTextProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewLabelEditUiaTextProvider.cs @@ -299,7 +299,7 @@ private int GetCharIndexFromPosition(Point pt) private RECT GetFormattingRectangle() { // Send an EM_GETRECT message to find out the bounding rectangle. - RECT rectangle = default(RECT); + RECT rectangle = default; PInvoke.SendMessage(_owningChildEdit, PInvoke.EM_GETRECT, 0, ref rectangle); return rectangle; @@ -319,9 +319,9 @@ private Point GetPositionFromCharIndex(int index) private unsafe bool GetTextExtentPoint32(char item, out Size size) { - size = default(Size); + size = default; - using var hdc = new GetDcScope(_owningChildEdit.Handle); + using GetDcScope hdc = new(_owningChildEdit.Handle); if (hdc.IsNull) { return false; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.cs index 57fa76f56bb..62973153379 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MDIClient.cs @@ -22,7 +22,7 @@ public sealed partial class MdiClient : Control { // kept in add order, not ZOrder. Need to return the correct // array of items... - private readonly List
_children = new List(); + private readonly List _children = new(); /// /// Creates a new MdiClient. @@ -276,7 +276,7 @@ protected override unsafe void SetBoundsCore(int x, int y, int width, int height /// private void SetWindowRgn() { - RECT rect = default(RECT); + RECT rect = default; CreateParams cp = CreateParams; AdjustWindowRectExForControlDpi(ref rect, (WINDOW_STYLE)cp.Style, false, (WINDOW_EX_STYLE)cp.ExStyle); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.cs index f1d5134e73b..7ff7190085b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MaskedTextBox.cs @@ -38,11 +38,11 @@ public partial class MaskedTextBox : TextBoxBase private const bool backward = false; private const string nullMask = "<>"; // any char/str is OK here. - private static readonly object EVENT_MASKINPUTREJECTED = new object(); - private static readonly object EVENT_VALIDATIONCOMPLETED = new object(); - private static readonly object EVENT_TEXTALIGNCHANGED = new object(); - private static readonly object EVENT_ISOVERWRITEMODECHANGED = new object(); - private static readonly object EVENT_MASKCHANGED = new object(); + private static readonly object EVENT_MASKINPUTREJECTED = new(); + private static readonly object EVENT_VALIDATIONCOMPLETED = new(); + private static readonly object EVENT_TEXTALIGNCHANGED = new(); + private static readonly object EVENT_ISOVERWRITEMODECHANGED = new(); + private static readonly object EVENT_MASKCHANGED = new(); // The native edit control's default password char (per thread). See corresponding property for more info. private static char systemPwdChar; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.cs index 5e12b40450c..a9553cb4779 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MenuStrip.cs @@ -13,8 +13,8 @@ public partial class MenuStrip : ToolStrip { private ToolStripMenuItem? _mdiWindowListItem; - private static readonly object EventMenuActivate = new object(); - private static readonly object EventMenuDeactivate = new object(); + private static readonly object EventMenuActivate = new(); + private static readonly object EventMenuDeactivate = new(); public MenuStrip() { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MenuTimer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MenuTimer.cs index 20223be40b2..d7b773dac48 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MenuTimer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MenuTimer.cs @@ -6,7 +6,7 @@ namespace System.Windows.Forms; internal class MenuTimer { - private readonly Timer _autoMenuExpandTimer = new Timer(); + private readonly Timer _autoMenuExpandTimer = new(); // consider - weak reference? private ToolStripMenuItem? currentItem; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarButtonAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarButtonAccessibleObject.cs index b0b3d05b097..c9a4200cf38 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarButtonAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.CalendarButtonAccessibleObject.cs @@ -120,7 +120,7 @@ private static unsafe void SendMouseInput(int x, int y, MOUSE_EVENT_FLAGS flags) flags |= MOUSE_EVENT_FLAGS.MOUSEEVENTF_VIRTUALDESK; } - INPUT mouseInput = default(INPUT); + INPUT mouseInput = default; mouseInput.type = INPUT_TYPE.INPUT_MOUSE; mouseInput.Anonymous.mi.dx = x; mouseInput.Anonymous.mi.dy = y; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.cs index 4b34274aa47..b9ac9a54193 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MonthCalendar.cs @@ -322,7 +322,7 @@ protected override CreateParams CreateParams protected override ImeMode DefaultImeMode => ImeMode.Disable; - protected override Padding DefaultMargin => new Padding(9); + protected override Padding DefaultMargin => new(9); protected override Size DefaultSize => GetMinReqRect(); @@ -767,7 +767,7 @@ public DateTime SelectionStart [Bindable(true)] public SelectionRange SelectionRange { - get => new SelectionRange(SelectionStart, SelectionEnd); + get => new(SelectionStart, SelectionEnd); set => SetSelectionRange(value.Start, value.End); } @@ -857,7 +857,7 @@ public Size SingleMonthSize { if (IsHandleCreated) { - RECT rect = default(RECT); + RECT rect = default; if (PInvoke.SendMessage(this, PInvoke.MCM_GETMINREQRECT, 0, ref rect) == 0) { throw new InvalidOperationException(SR.InvalidSingleMonthSize); @@ -921,7 +921,7 @@ public DateTime TodayDate if (IsHandleCreated) { - SYSTEMTIME systemTime = default(SYSTEMTIME); + SYSTEMTIME systemTime = default; int result = (int)PInvoke.SendMessage(this, PInvoke.MCM_GETTODAY, 0, ref systemTime); Debug.Assert(result != 0, "MCM_GETTODAY failed"); return ((DateTime)systemTime).Date; @@ -1384,7 +1384,7 @@ public unsafe HitTestInfo HitTest(int x, int y) { cbSize = (uint)sizeof(MCHITTESTINFO), pt = new Point(x, y), - st = default(SYSTEMTIME) + st = default }; PInvoke.SendMessage(this, PInvoke.MCM_HITTEST, 0, ref mchi); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/MouseHoverTimer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/MouseHoverTimer.cs index 251a2e19436..627a085111b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/MouseHoverTimer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/MouseHoverTimer.cs @@ -6,7 +6,7 @@ namespace System.Windows.Forms; internal class MouseHoverTimer : IDisposable { - private Timer _mouseHoverTimer = new Timer(); + private Timer _mouseHoverTimer = new(); // Consider - weak reference? private ToolStripItem? _currentItem; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.WindowClass.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.WindowClass.cs index 6c68b4a2e33..c637b9817c1 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.WindowClass.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.WindowClass.cs @@ -118,7 +118,7 @@ private static string GetFullClassName(string className) ///
private unsafe void RegisterClass() { - WNDCLASSW windowClass = default(WNDCLASSW); + WNDCLASSW windowClass = default; string? localClassName = _className; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.cs b/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.cs index f935952518f..6a6a7c5a5b0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/NotifyIcon.cs @@ -21,21 +21,21 @@ namespace System.Windows.Forms; public sealed partial class NotifyIcon : Component { internal const int MaxTextSize = 127; - private static readonly object EVENT_MOUSEDOWN = new object(); - private static readonly object EVENT_MOUSEMOVE = new object(); - private static readonly object EVENT_MOUSEUP = new object(); - private static readonly object EVENT_CLICK = new object(); - private static readonly object EVENT_DOUBLECLICK = new object(); - private static readonly object EVENT_MOUSECLICK = new object(); - private static readonly object EVENT_MOUSEDOUBLECLICK = new object(); - private static readonly object EVENT_BALLOONTIPSHOWN = new object(); - private static readonly object EVENT_BALLOONTIPCLICKED = new object(); - private static readonly object EVENT_BALLOONTIPCLOSED = new object(); + private static readonly object EVENT_MOUSEDOWN = new(); + private static readonly object EVENT_MOUSEMOVE = new(); + private static readonly object EVENT_MOUSEUP = new(); + private static readonly object EVENT_CLICK = new(); + private static readonly object EVENT_DOUBLECLICK = new(); + private static readonly object EVENT_MOUSECLICK = new(); + private static readonly object EVENT_MOUSEDOUBLECLICK = new(); + private static readonly object EVENT_BALLOONTIPSHOWN = new(); + private static readonly object EVENT_BALLOONTIPCLICKED = new(); + private static readonly object EVENT_BALLOONTIPCLOSED = new(); private const int WM_TRAYMOUSEMESSAGE = (int)PInvoke.WM_USER + 1024; private static readonly MessageId WM_TASKBARCREATED = PInvoke.RegisterWindowMessage("TaskbarCreated"); - private readonly object _syncObj = new object(); + private readonly object _syncObj = new(); private Icon? _icon; private string _text = string.Empty; @@ -569,13 +569,14 @@ public unsafe void ShowBalloonTip(int timeout, string tipTitle, string tipText, return; } - var data = new NOTIFYICONDATAW + NOTIFYICONDATAW data = new() { cbSize = (uint)sizeof(NOTIFYICONDATAW), uFlags = NIF.INFO, uID = _id, uTimeoutOrVersion = (uint)timeout }; + if (_window.Handle == IntPtr.Zero) { _window.CreateHandle(new CreateParams()); @@ -639,13 +640,14 @@ private unsafe void UpdateIcon(bool showIconInTray) _window.LockReference(showIconInTray); - var data = new NOTIFYICONDATAW + NOTIFYICONDATAW data = new() { cbSize = (uint)sizeof(NOTIFYICONDATAW), uCallbackMessage = WM_TRAYMOUSEMESSAGE, uFlags = NIF.MESSAGE, uID = _id }; + if (showIconInTray) { if (_window.Handle == IntPtr.Zero) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/OSFeature.cs b/src/System.Windows.Forms/src/System/Windows/Forms/OSFeature.cs index d40a15854e5..4494712298e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/OSFeature.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/OSFeature.cs @@ -13,12 +13,12 @@ public class OSFeature : FeatureSupport /// Represents the layered, top-level windows feature. This field /// is read-only. ///
- public static readonly object LayeredWindows = new object(); + public static readonly object LayeredWindows = new(); /// /// Determines if the OS supports themes /// - public static readonly object Themes = new object(); + public static readonly object Themes = new(); private static OSFeature? _feature; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/OwnerDrawPropertyBag.cs b/src/System.Windows.Forms/src/System/Windows/Forms/OwnerDrawPropertyBag.cs index e9c75e69805..b426d999e0a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/OwnerDrawPropertyBag.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/OwnerDrawPropertyBag.cs @@ -14,7 +14,7 @@ namespace System.Windows.Forms; public class OwnerDrawPropertyBag : MarshalByRefObject, ISerializable { private Control.FontHandleWrapper? _fontWrapper; - private static readonly object s_internalSyncObject = new object(); + private static readonly object s_internalSyncObject = new(); protected OwnerDrawPropertyBag(SerializationInfo info, StreamingContext context) { @@ -71,7 +71,7 @@ public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag? value) { lock (s_internalSyncObject) { - var result = new OwnerDrawPropertyBag(); + OwnerDrawPropertyBag result = new(); if (value is null) { return result; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Panel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Panel.cs index fdfd8c3b3fb..0c2de527cbe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Panel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Panel.cs @@ -143,7 +143,7 @@ protected override CreateParams CreateParams /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. ///
- protected override Size DefaultSize => new Size(200, 100); + protected override Size DefaultSize => new(200, 100); internal override Size GetPreferredSizeCore(Size proposedSize) { @@ -226,7 +226,7 @@ private protected override void PrintToMetaFileRecursive(HDC hDC, IntPtr lParam, { base.PrintToMetaFileRecursive(hDC, lParam, bounds); - using var mapping = new DCMapping(hDC, bounds); + using DCMapping mapping = new(hDC, bounds); using Graphics g = hDC.CreateGraphics(); ControlPaint.PrintBorder(g, new Rectangle(Point.Empty, Size), BorderStyle, Border3DStyle.Sunken); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs index a3e01013643..beb9fbe0484 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PictureBox.cs @@ -62,7 +62,7 @@ public partial class PictureBox : Control, ISupportInitialize private SendOrPostCallback _loadCompletedDelegate; private SendOrPostCallback _loadProgressDelegate; private bool _handleValid; - private readonly object _internalSyncObject = new object(); + private readonly object _internalSyncObject = new(); // These default images will be demand loaded. private Image _defaultInitialImage; @@ -74,8 +74,8 @@ public partial class PictureBox : Control, ISupportInitialize [ThreadStatic] private static Image t_defaultErrorImageForThread; - private static readonly object s_loadCompletedKey = new object(); - private static readonly object s_loadProgressChangedKey = new object(); + private static readonly object s_loadCompletedKey = new(); + private static readonly object s_loadProgressChangedKey = new(); private const int AsyncOperationInProgressState = 0x00000001; private const int CancellationPendingState = 0x00000002; @@ -214,7 +214,7 @@ protected override CreateParams CreateParams /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. ///
- protected override Size DefaultSize => new Size(100, 50); + protected override Size DefaultSize => new(100, 50); [SRCategory(nameof(SR.CatAsynchronous))] [Localizable(true)] @@ -876,7 +876,7 @@ public PictureBoxSizeMode SizeMode } } - private static readonly object EVENT_SIZEMODECHANGED = new object(); + private static readonly object EVENT_SIZEMODECHANGED = new(); [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.PictureBoxOnSizeModeChangedDescr))] diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs index cec0bb1a2cb..c926a7d9611 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs @@ -18,8 +18,8 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionPrintPreviewControl))] public partial class PrintPreviewControl : Control { - private Size virtualSize = new Size(1, 1); - private Point position = new Point(0, 0); + private Size virtualSize = new(1, 1); + private Point position = new(0, 0); private Point lastOffset; private bool antiAlias; @@ -260,7 +260,7 @@ public int StartPage } } - private static readonly object EVENT_STARTPAGECHANGED = new object(); + private static readonly object EVENT_STARTPAGECHANGED = new(); [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.RadioButtonOnStartPageChangedDescr))] @@ -581,7 +581,7 @@ protected override void OnPaint(PaintEventArgs pevent) Point lastImageSize = Point.Empty; int maxImageHeight = 0; - using (var clipScope = new GraphicsClipScope(pevent.GraphicsInternal)) + using (GraphicsClipScope clipScope = new(pevent.GraphicsInternal)) { for (int row = 0; row < rows; row++) { @@ -611,7 +611,8 @@ protected override void OnPaint(PaintEventArgs pevent) int y = offset.Y + borderPixelsY * (row + 1) + lastImageSize.Y; lastImageSize.X += imagePixels.X; - //The Height is the Max of any PageHeight.. + + // The Height is the Max of any PageHeight. maxImageHeight = Math.Max(maxImageHeight, imagePixels.Y); pageRenderArea[imageIndex - StartPage] = new Rectangle(x, y, imagePixels.X, imagePixels.Y); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.cs index 4452c2703dd..8375c47a482 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ProgressBar.cs @@ -158,7 +158,7 @@ public override ImageLayout BackgroundImageLayout protected override ImeMode DefaultImeMode => ImeMode.Disable; - protected override Size DefaultSize => new Size(100, 23); + protected override Size DefaultSize => new(100, 23); [EditorBrowsable(EditorBrowsableState.Never)] protected override bool DoubleBuffered diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs index 1d38c15559e..ea14da90663 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGrid.cs @@ -909,7 +909,7 @@ public object[] SelectedObjects get => _selectedObjects is null ? Array.Empty() : (object[])_selectedObjects.Clone(); set { - using var _ = new FreezePaintScope(this); + using FreezePaintScope _ = new(this); SetFlag(Flags.FullRefreshAfterBatch, false); if (GetFlag(Flags.BatchMode)) @@ -2572,7 +2572,7 @@ private void OnLayoutInternal(bool dividerOnly) return; } - using var _ = new FreezePaintScope(this); + using FreezePaintScope _ = new(this); if (!dividerOnly) { @@ -3030,7 +3030,7 @@ private void OnTypeDescriptorRefreshedInvoke(RefreshEventArgs e) private void OnViewSortButtonClick(object sender, EventArgs e) { - using (var _ = new FreezePaintScope(this)) + using (FreezePaintScope _ = new(this)) { // Is this tab selected? If so, do nothing. if (sender == _viewSortButtons[_selectedViewSort]) @@ -3079,7 +3079,7 @@ private void OnViewSortButtonClick(object sender, EventArgs e) private void OnViewTabButtonClick(object sender, EventArgs e) { - using (var _ = new FreezePaintScope(this)) + using (FreezePaintScope _ = new(this)) { SelectViewTabButton((ToolStripButton)sender, true); OnLayoutInternal(dividerOnly: false); @@ -3792,7 +3792,7 @@ private void SetupToolbar(bool fullRebuild) return; } - using var _ = new FreezePaintScope(this); + using FreezePaintScope _ = new(this); if (_normalButtonImages is null || fullRebuild) { @@ -4060,7 +4060,7 @@ private bool ShouldForwardChildMouseMessage(Control child, MouseEventArgs e, ref if (e.Y <= 1 || (size.Height - e.Y) <= 1) { // Convert the coordinates. - var temp = new Point(e.X, e.Y); + Point temp = new(e.X, e.Y); temp = WindowsFormsUtils.TranslatePoint(temp, child, this); // Forward the message. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.cs index 7831f5a6ff3..731647595bd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/DropDownButton.cs @@ -82,13 +82,13 @@ protected override void OnPaint(PaintEventArgs pevent) state = ComboBoxState.Hot; } - Rectangle dropDownButtonRect = new Rectangle(0, 0, Width, Height); + Rectangle dropDownButtonRect = new(0, 0, Width, Height); if (state == ComboBoxState.Normal) { pevent.Graphics.FillRectangle(SystemBrushes.Window, dropDownButtonRect); } - using (var hdc = new DeviceContextHdcScope(pevent)) + using (DeviceContextHdcScope hdc = new(pevent)) { ComboBoxRenderer.DrawDropDownButtonForHandle( hdc, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.cs index 89d62b727ac..58d944dccad 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/GridEntry.cs @@ -1635,7 +1635,7 @@ void PaintOutlineWithExplorerTreeStyle(Graphics g, Rectangle r, HWND hwnd) } else { - using var hdc = new DeviceContextHdcScope(g); + using DeviceContextHdcScope hdc = new(g); VisualStyleRenderer explorerTreeRenderer = new(VisualStyleElement.ExplorerTreeView.Glyph.Opened); explorerTreeRenderer.DrawBackground(hdc, outline, hwnd); } @@ -1647,7 +1647,7 @@ unsafe void RedrawExplorerTreeViewClosedGlyph( HWND hwnd) { Color backgroundColor = ColorInversionNeededInHighContrast ? InvertColor(OwnerGrid.LineColor) : OwnerGrid.LineColor; - using var compatibleDC = new PInvoke.CreateDcScope(default); + using PInvoke.CreateDcScope compatibleDC = new(default); int planes = PInvoke.GetDeviceCaps(compatibleDC, GET_DEVICE_CAPS_INDEX.PLANES); int bitsPixel = PInvoke.GetDeviceCaps(compatibleDC, GET_DEVICE_CAPS_INDEX.BITSPIXEL); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.PropertyGridViewAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.PropertyGridViewAccessibleObject.cs index 699407593d9..320931cd70f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.PropertyGridViewAccessibleObject.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.PropertyGridViewAccessibleObject.cs @@ -423,7 +423,7 @@ public override int GetChildCount() => } // Convert to client coordinates - var point = new Point(x, y); + Point point = new(x, y); PInvoke.ScreenToClient(owner, ref point); // Find the grid entry at the given client coordinates diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.cs index eaf12681ba3..7d6b10fd2fe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/PropertyGridView.cs @@ -605,7 +605,7 @@ internal Rectangle AccessibilityGetGridEntryBounds(GridEntry gridEntry) Rectangle rect = GetRectangle(row, RowValue | RowLabel); // Translate rect to screen coordinates - var pt = new Point(rect.X, rect.Y); + Point pt = new(rect.X, rect.Y); PInvoke.ClientToScreen(this, ref pt); Rectangle parent = gridEntry.OwnerGrid.GridViewAccessibleObject.Bounds; @@ -1154,7 +1154,7 @@ private void DrawLabel(Graphics g, int row, Rectangle rect, bool selected, bool s_gridViewDebugPaint.TraceVerbose($"Drawing label for property {gridEntry.PropertyLabel}"); - var newOrigin = new Point(rect.X, rect.Y); + Point newOrigin = new(rect.X, rect.Y); clipRect = Rectangle.Intersect(rect, clipRect); if (clipRect.IsEmpty) @@ -1206,7 +1206,7 @@ private void DrawValue(Graphics g, int row, Rectangle clipRect) s_gridViewDebugPaint.TraceVerbose($"Drawing value for property {gridEntry.PropertyLabel}"); Rectangle rect = GetRectangle(row, RowValue); - var newOrigin = new Point(rect.X, rect.Y); + Point newOrigin = new(rect.X, rect.Y); clipRect = Rectangle.Intersect(clipRect, rect); if (clipRect.IsEmpty) @@ -1711,7 +1711,7 @@ private Point FindPosition(int x, int y) return InvalidPosition; } - var pt = new Point(RowLabel, 0); + Point pt = new(RowLabel, 0); if (x > LabelWidth + _location.X) { pt.X = RowValue; @@ -1934,7 +1934,7 @@ private Size GetOurSize() public Rectangle GetRectangle(int row, int flRow) { - var rect = new Rectangle(0, 0, 0, 0); + Rectangle rect = new(0, 0, 0, 0); Size size = GetOurSize(); rect.X = _location.X; @@ -2021,7 +2021,7 @@ public string GetTestingInfo(int entry) private void LayoutWindow(bool invalidate) { Rectangle rect = ClientRectangle; - var sizeWindow = new Size(rect.Width, rect.Height); + Size sizeWindow = new(rect.Width, rect.Height); if (_scrollBar is not null) { @@ -2424,7 +2424,7 @@ protected override void OnLostFocus(EventArgs e) // For empty GridView, clear the focus indicator that was painted in OnGotFocus() if (TotalProperties <= 0) { - var clearRect = new Rectangle(1, 1, Size.Width - 2, Size.Height - 2); + Rectangle clearRect = new(1, 1, Size.Width - 2, Size.Height - 2); s_gridViewDebugPaint.TraceVerbose($"Filling empty gridview rect={clearRect}"); Color color = BackColor; @@ -3447,7 +3447,7 @@ protected override void OnPaint(PaintEventArgs e) if (yPosition < Size.Height) { yPosition++; - var clearRect = new Rectangle(1, yPosition, Size.Width - 2, Size.Height - yPosition - 1); + Rectangle clearRect = new(1, yPosition, Size.Width - 2, Size.Height - yPosition - 1); s_gridViewDebugPaint.TraceVerbose($"Filling remaining area rect={clearRect}"); using var backBrush = BackColor.GetCachedSolidBrushScope(); @@ -3683,13 +3683,13 @@ protected override void OnResize(EventArgs e) if (!_lastClientRect.IsEmpty && newRect.Width > _lastClientRect.Width) { - var rectInvalidate = new Rectangle(_lastClientRect.Width - 1, 0, newRect.Width - _lastClientRect.Width + 1, _lastClientRect.Height); + Rectangle rectInvalidate = new(_lastClientRect.Width - 1, 0, newRect.Width - _lastClientRect.Width + 1, _lastClientRect.Height); Invalidate(rectInvalidate); } if (!_lastClientRect.IsEmpty && yDelta > 0) { - var rectInvalidate = new Rectangle(0, _lastClientRect.Height - 1, _lastClientRect.Width, newRect.Height - _lastClientRect.Height + 1); + Rectangle rectInvalidate = new(0, _lastClientRect.Height - 1, _lastClientRect.Width, newRect.Height - _lastClientRect.Height + 1); Invalidate(rectInvalidate); } @@ -3793,7 +3793,7 @@ public unsafe void PopupEditor(int row) // The listbox draws with GDI, not GDI+. So we use a normal DC here. - using var hdc = new GetDcScope(DropDownListBox.HWND); + using GetDcScope hdc = new(DropDownListBox.HWND); TEXTMETRICW tm = default; int selectionIndex = -1; @@ -4447,7 +4447,7 @@ private void SelectRow(int row) ? new Size(SystemInformation.VerticalScrollBarArrowHeightForDpi(_deviceDpi), RowHeight) : new Size(SystemInformation.VerticalScrollBarArrowHeight, RowHeight); - var rectTarget = new Rectangle( + Rectangle rectTarget = new( rect.X + rect.Width - sizeBtn.Width, rect.Y, sizeBtn.Width, rect.Height); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.cs index 8c4a84bb1e2..133d6a6f6dd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridToolStripButton.cs @@ -43,16 +43,16 @@ private void DrawDashedBorer(Graphics graphics) private void DrawHightContrastDashedBorer(Graphics graphics) { - var bounds = ClientBounds; + Rectangle bounds = ClientBounds; float[] dashValues = { 2, 2 }; int penWidth = 2; - var focusPen1 = new Pen(SystemColors.ControlText, penWidth) + Pen focusPen1 = new(SystemColors.ControlText, penWidth) { DashPattern = dashValues }; - var focusPen2 = new Pen(SystemColors.Control, penWidth) + Pen focusPen2 = new(SystemColors.Control, penWidth) { DashPattern = dashValues, DashOffset = 2 diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.cs index 6c638d554f5..8ea4ce636c0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButton.cs @@ -23,7 +23,7 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionRadioButton))] public partial class RadioButton : ButtonBase { - private static readonly object EVENT_CHECKEDCHANGED = new object(); + private static readonly object EVENT_CHECKEDCHANGED = new(); private const ContentAlignment AnyRight = ContentAlignment.TopRight | ContentAlignment.MiddleRight | ContentAlignment.BottomRight; // Used to see if we need to iterate through the autochecked items and modify their tabstops. @@ -125,7 +125,7 @@ public Appearance Appearance } } - private static readonly object EVENT_APPEARANCECHANGED = new object(); + private static readonly object EVENT_APPEARANCECHANGED = new(); [SRCategory(nameof(SR.CatPropertyChanged))] [SRDescription(nameof(SR.RadioButtonOnAppearanceChangedDescr))] @@ -250,7 +250,7 @@ protected override CreateParams CreateParams } } - protected override Size DefaultSize => new Size(104, 24); + protected override Size DefaultSize => new(104, 24); /// /// When overridden in a derived class, handles rescaling of any magic numbers used in control painting. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButtonRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButtonRenderer.cs index 8a57616f87d..f21ea16abd5 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RadioButtonRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RadioButtonRenderer.cs @@ -80,7 +80,7 @@ internal static void DrawRadioButtonWithVisualStyles( HWND hwnd) { InitializeRenderer((int)state); - Rectangle glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); + Rectangle glyphBounds = new(glyphLocation, GetGlyphSize(hdc, state, hwnd)); t_visualStyleRenderer.DrawBackground(hdc, glyphBounds, hwnd); } @@ -93,12 +93,12 @@ internal static void DrawRadioButton( Rectangle glyphBounds; if (RenderWithVisualStyles) { - using var hdc = new DeviceContextHdcScope(graphics); + using DeviceContextHdcScope hdc = new(graphics); DrawRadioButtonWithVisualStyles(hdc, glyphLocation, state, hwnd); } else { - using (var hdc = new DeviceContextHdcScope(graphics)) + using (DeviceContextHdcScope hdc = new(graphics)) { glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); } @@ -152,7 +152,7 @@ internal static void DrawRadioButton( HWND hwnd) { Rectangle glyphBounds; - using (var hdc = new DeviceContextHdcScope(g)) + using (DeviceContextHdcScope hdc = new(g)) { glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); } @@ -244,7 +244,7 @@ internal static void DrawRadioButton( HWND hwnd) { Rectangle glyphBounds; - using (var hdc = new DeviceContextHdcScope(g)) + using (DeviceContextHdcScope hdc = new(g)) { glyphBounds = new Rectangle(glyphLocation, GetGlyphSize(hdc, state, hwnd)); } @@ -280,7 +280,7 @@ internal static void DrawRadioButton( /// public static Size GetGlyphSize(Graphics g, RadioButtonState state) { - using var hdc = new DeviceContextHdcScope(g); + using DeviceContextHdcScope hdc = new(g); return GetGlyphSize(hdc, state, HWND.Null); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RelatedCurrencyManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RelatedCurrencyManager.cs index b979c831bcd..ecb228613bd 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RelatedCurrencyManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RelatedCurrencyManager.cs @@ -18,7 +18,7 @@ internal class RelatedCurrencyManager : CurrencyManager private BindingManagerBase parentManager; private string dataField; private PropertyDescriptor fieldInfo; - private static readonly List IgnoreItemChangedTable = new List(); + private static readonly List IgnoreItemChangedTable = new(); internal RelatedCurrencyManager(BindingManagerBase parentManager, string dataField) : base(null) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs index 7e74c813453..2ccf8f56c5d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/RichTextBox.cs @@ -59,13 +59,13 @@ private static TraceSwitch RichTextDbg // Event objects // - private static readonly object EVENT_HSCROLL = new object(); - private static readonly object EVENT_LINKACTIVATE = new object(); - private static readonly object EVENT_IMECHANGE = new object(); - private static readonly object EVENT_PROTECTED = new object(); - private static readonly object EVENT_REQUESTRESIZE = new object(); - private static readonly object EVENT_SELCHANGE = new object(); - private static readonly object EVENT_VSCROLL = new object(); + private static readonly object EVENT_HSCROLL = new(); + private static readonly object EVENT_LINKACTIVATE = new(); + private static readonly object EVENT_IMECHANGE = new(); + private static readonly object EVENT_PROTECTED = new(); + private static readonly object EVENT_REQUESTRESIZE = new(); + private static readonly object EVENT_SELCHANGE = new(); + private static readonly object EVENT_VSCROLL = new(); // Persistent state // @@ -366,7 +366,7 @@ public bool DetectUrls } } - protected override Size DefaultSize => new Size(100, 96); + protected override Size DefaultSize => new(100, 96); /// /// We can't just enable drag/drop of text by default: it's a breaking change. @@ -687,7 +687,7 @@ public unsafe HorizontalAlignment SelectionAlignment HorizontalAlignment selectionAlignment = HorizontalAlignment.Left; ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -722,7 +722,7 @@ public unsafe HorizontalAlignment SelectionAlignment SourceGenerated.EnumValidator.Validate(value); ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.ALIGNMENT @@ -763,7 +763,7 @@ public unsafe bool SelectionBullet RichTextBoxSelectionAttribute selectionBullet = RichTextBoxSelectionAttribute.None; ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -791,7 +791,7 @@ public unsafe bool SelectionBullet { ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.NUMBERING | PFM.OFFSET @@ -841,7 +841,7 @@ public unsafe int SelectionCharOffset } ForceHandleCreate(); - var cf = new CHARFORMAT2W + CHARFORMAT2W cf = new() { cbSize = (uint)sizeof(CHARFORMAT2W), dwMask = CFM.OFFSET, @@ -933,10 +933,11 @@ public unsafe Color SelectionBackColor _selectionBackColorToSetOnHandleCreated = value; if (IsHandleCreated) { - var cf2 = new CHARFORMAT2W + CHARFORMAT2W cf2 = new() { cbSize = (uint)sizeof(CHARFORMAT2W) }; + if (value == Color.Empty) { cf2.dwEffects = CFE.AUTOBACKCOLOR; @@ -983,7 +984,7 @@ public unsafe int SelectionHangingIndent int selHangingIndent = 0; ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1003,7 +1004,7 @@ public unsafe int SelectionHangingIndent { ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.OFFSET, @@ -1031,7 +1032,7 @@ public unsafe int SelectionIndent int selIndent = 0; ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1051,7 +1052,7 @@ public unsafe int SelectionIndent { ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.STARTINDENT, @@ -1153,7 +1154,7 @@ public unsafe int SelectionRightIndent ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1180,7 +1181,7 @@ public unsafe int SelectionRightIndent } ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT), dwMask = PFM.RIGHTINDENT, @@ -1206,7 +1207,7 @@ public unsafe int[] SelectionTabs int[] selTabs = Array.Empty(); ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1235,7 +1236,7 @@ public unsafe int[] SelectionTabs } ForceHandleCreate(); - var pf = new PARAFORMAT + PARAFORMAT pf = new() { cbSize = (uint)sizeof(PARAFORMAT) }; @@ -1414,7 +1415,7 @@ public override unsafe int TextLength { get { - var gtl = new GETTEXTLENGTHEX + GETTEXTLENGTHEX gtl = new() { flags = GTL.NUMCHARS, codepage = 1200u /* CP_UNICODE */ @@ -1844,7 +1845,7 @@ public unsafe int Find(string str, int start, int end, RichTextBoxFinds options) throw new ArgumentException(string.Format(SR.RichTextFindEndInvalid, end)); } - var ft = default(FINDTEXTW); + FINDTEXTW ft = default; if ((options & RichTextBoxFinds.Reverse) != RichTextBoxFinds.Reverse) { // normal @@ -2156,7 +2157,7 @@ private bool InternalSetForeColor(Color value) private unsafe CHARFORMAT2W GetCharFormat(bool fSelection) { - var cf = new CHARFORMAT2W + CHARFORMAT2W cf = new() { cbSize = (uint)sizeof(CHARFORMAT2W) }; @@ -2244,7 +2245,7 @@ private RichTextBoxSelectionAttribute GetCharFormat(CFM mask, CFE effect) /// public override int GetCharIndexFromPosition(Point pt) { - var wpt = new Point(pt.X, pt.Y); + Point wpt = new(pt.X, pt.Y); int index = (int)PInvoke.SendMessage(this, PInvoke.EM_CHARFROMPOS, 0, ref wpt); string t = Text; @@ -2299,9 +2300,9 @@ public override unsafe Point GetPositionFromCharIndex(int index) return Point.Empty; } - var pt = default(Point); - PInvoke.SendMessage(this, PInvoke.EM_POSFROMCHAR, (WPARAM)(&pt), index); - return pt; + Point position = default; + PInvoke.SendMessage(this, PInvoke.EM_POSFROMCHAR, (WPARAM)(&position), index); + return position; } private bool GetProtectedError() @@ -2742,7 +2743,7 @@ private unsafe bool SetCharFormat(CFM mask, CFE effect, RichTextBoxSelectionAttr // check to see if the control has been created if (IsHandleCreated) { - var cf = new CHARFORMAT2W + CHARFORMAT2W cf = new() { cbSize = (uint)sizeof(CHARFORMAT2W), dwMask = mask @@ -2760,7 +2761,7 @@ private unsafe bool SetCharFormat(CFM mask, CFE effect, RichTextBoxSelectionAttr throw new ArgumentException(SR.UnknownAttr); } - // set the format information + // Set the format information. return PInvoke.SendMessage(this, PInvoke.EM_SETCHARFORMAT, (WPARAM)(uint)SCF.SELECTION, ref cf) != 0; } @@ -2886,11 +2887,11 @@ private void StreamIn(string str, SF flags) private void StreamIn(Stream data, SF flags) { - // clear out the selection only if we are replacing all the text + // Clear out the selection only if we are replacing all the text. if ((flags & SF.F_SELECTION) == 0) { - var cr = default(CHARRANGE); - PInvoke.SendMessage(this, PInvoke.EM_EXSETSEL, 0, ref cr); + CHARRANGE range = default; + PInvoke.SendMessage(this, PInvoke.EM_EXSETSEL, 0, ref range); } try @@ -2921,7 +2922,7 @@ private void StreamIn(Stream data, SF flags) int cookieVal = 0; // set up structure to do stream operation - var es = default(EDITSTREAM); + EDITSTREAM es = default; if ((flags & SF.UNICODE) != 0) { @@ -2942,7 +2943,7 @@ private void StreamIn(Stream data, SF flags) } es.dwCookie = (UIntPtr)cookieVal; - var callback = new EDITSTREAMCALLBACK(EditStreamProc); + EDITSTREAMCALLBACK callback = EditStreamProc; es.pfnCallback = Marshal.GetFunctionPointerForDelegate(callback); // gives us TextBox compatible behavior, programatic text change shouldn't @@ -3025,15 +3026,9 @@ private void StreamOut(Stream data, SF flags, bool includeCrLfs) try { int cookieVal = 0; - var es = default(EDITSTREAM); - if ((flags & SF.UNICODE) != 0) - { - cookieVal = OUTPUT | UNICODE; - } - else - { - cookieVal = OUTPUT | ANSI; - } + EDITSTREAM es = default; + + cookieVal = (flags & SF.UNICODE) != 0 ? OUTPUT | UNICODE : OUTPUT | ANSI; if ((flags & SF.RTF) != 0) { @@ -3052,7 +3047,7 @@ private void StreamOut(Stream data, SF flags, bool includeCrLfs) } es.dwCookie = (UIntPtr)cookieVal; - var callback = new EDITSTREAMCALLBACK(EditStreamProc); + EDITSTREAMCALLBACK callback = EditStreamProc; es.pfnCallback = Marshal.GetFunctionPointerForDelegate(callback); // Get Text @@ -3225,7 +3220,7 @@ private unsafe void EnLinkMsgHandler(ref Message m) /// private string CharRangeToString(CHARRANGE c) { - var txrg = new Richedit.TEXTRANGE + Richedit.TEXTRANGE txrg = new() { chrg = c }; @@ -3237,7 +3232,7 @@ private string CharRangeToString(CHARRANGE c) } int characters = (c.cpMax - c.cpMin) + 1; // +1 for null termination - var charBuffer = new UnicodeCharBuffer(characters); + UnicodeCharBuffer charBuffer = new(characters); IntPtr unmanagedBuffer = charBuffer.AllocCoTaskMem(); if (unmanagedBuffer == IntPtr.Zero) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Screen.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Screen.cs index 00300275596..b06915c1847 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Screen.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Screen.cs @@ -37,7 +37,7 @@ public partial class Screen private readonly int _bitDepth; - private static readonly object s_syncLock = new object(); //used to lock this class before syncing to SystemEvents + private static readonly object s_syncLock = new(); //used to lock this class before syncing to SystemEvents private static int s_desktopChangedCount = -1; //static counter of desktop size changes diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.cs index f5743c8d231..ca1531d7385 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollBar.cs @@ -15,8 +15,8 @@ namespace System.Windows.Forms; [DefaultEvent(nameof(Scroll))] public abstract partial class ScrollBar : Control { - private static readonly object s_scrollEvent = new object(); - private static readonly object s_valueChangedEvent = new object(); + private static readonly object s_scrollEvent = new(); + private static readonly object s_valueChangedEvent = new(); private int _minimum; private int _maximum = 100; @@ -719,7 +719,7 @@ private unsafe void DoScroll(ScrollEventType type) break; } - var se = new ScrollEventArgs(type, oldValue, newValue, _scrollOrientation); + ScrollEventArgs se = new(type, oldValue, newValue, _scrollOrientation); OnScroll(se); Value = se.NewValue; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.cs index 3d7c48a1442..33d4c0e1c3f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ScrollableControl.cs @@ -15,7 +15,7 @@ namespace System.Windows.Forms; public partial class ScrollableControl : Control, IArrangedElement { #if DEBUG - internal static readonly TraceSwitch s_autoScrolling = new TraceSwitch("AutoScrolling", "Debug autoscrolling logic"); + internal static readonly TraceSwitch s_autoScrolling = new("AutoScrolling", "Debug autoscrolling logic"); #else internal static readonly TraceSwitch? s_autoScrolling; #endif @@ -60,7 +60,7 @@ public partial class ScrollableControl : Control, IArrangedElement private HScrollProperties? _horizontalScroll; - private static readonly object s_scrollEvent = new object(); + private static readonly object s_scrollEvent = new(); /// /// Used to figure out what the horizontal scroll value should be set to when the horizontal diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.cs index b1e7542736b..116364f154d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SendKeys.cs @@ -85,9 +85,9 @@ public partial class SendKeys /// /// Vector of events that we have yet to post to the journaling hook. /// - private static readonly Queue s_events = new Queue(); + private static readonly Queue s_events = new(); - private static object s_lock = new object(); + private static object s_lock = new(); private static bool s_startNewChar; private static readonly SKWindow s_messageWindow; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.SpecialFolderEnumComparer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.SpecialFolderEnumComparer.cs index 9d37c5d9019..2ad100e3939 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.SpecialFolderEnumComparer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SpecialFolderEnumConverter.SpecialFolderEnumComparer.cs @@ -10,7 +10,7 @@ internal partial class SpecialFolderEnumConverter { private class SpecialFolderEnumComparer : IComparer { - public static readonly SpecialFolderEnumComparer Default = new SpecialFolderEnumComparer(); + public static readonly SpecialFolderEnumComparer Default = new(); public int Compare(object? a, object? b) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.cs index 8c9f4631c2e..769900031be 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitContainer.cs @@ -79,8 +79,8 @@ public partial class SplitContainer : ContainerControl, ISupportInitialize private bool _setSplitterDistance; // Events - private static readonly object s_eventMoving = new object(); - private static readonly object s_eventMoved = new object(); + private static readonly object s_eventMoving = new(); + private static readonly object s_eventMoved = new(); // IMessageFilter implementation private SplitContainerMessageFilter? _splitContainerMessageFilter; @@ -99,7 +99,7 @@ public SplitContainer() // either the right or bottom panel - LTR // either the left or bottom panel - RTL Panel2 = new SplitterPanel(this); - _splitterRect = default(Rectangle); + _splitterRect = default; SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); @@ -1388,7 +1388,7 @@ private void ApplySplitterDistance() /// private Rectangle CalcSplitLine(int splitSize, int minWeight) { - Rectangle r = default(Rectangle); + Rectangle r = default; switch (Orientation) { case Orientation.Vertical: diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.cs index 56bc1170e62..e52a87df4ea 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Splitter.cs @@ -36,8 +36,8 @@ public partial class Splitter : Control private int _initTargetSize; private int _lastDrawSplit = -1; private int _maxSize; - private static readonly object EVENT_MOVING = new object(); - private static readonly object EVENT_MOVED = new object(); + private static readonly object EVENT_MOVING = new(); + private static readonly object EVENT_MOVED = new(); // Cannot expose IMessageFilter.PreFilterMessage through this unsealed class private SplitterMessageFilter? _splitterMessageFilter; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterPanel.cs index ee291bef083..e38a43a7189 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SplitterPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SplitterPanel.cs @@ -151,7 +151,7 @@ internal int HeightInternal /// /// A new instance of the struct with the padding set to 0 for all edges. /// - protected override Padding DefaultMargin => new Padding(0, 0, 0, 0); + protected override Padding DefaultMargin => new(0, 0, 0, 0); /// /// Override AutoSize to make it hidden from the user in the designer diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/SystemInformation.cs b/src/System.Windows.Forms/src/System/Windows/Forms/SystemInformation.cs index 228d39452c3..f8848217e5e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/SystemInformation.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/SystemInformation.cs @@ -196,9 +196,9 @@ public static Rectangle WorkingArea { get { - var rect = default(RECT); - PInvoke.SystemParametersInfo(SPI_GETWORKAREA, ref rect); - return rect; + RECT workingArea = default; + PInvoke.SystemParametersInfo(SPI_GETWORKAREA, ref workingArea); + return workingArea; } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabPageCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabPageCollection.cs index 539df1e2c94..f23c274f049 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabPageCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.TabPageCollection.cs @@ -97,46 +97,30 @@ int IList.Add(object? value) return IndexOf(tabPage); } - public void Add(string? text) + public void Add(string? text) => Add(new TabPage { - var page = new TabPage - { - Text = text - }; - Add(page); - } + Text = text + }); - public void Add(string? key, string? text) + public void Add(string? key, string? text) => Add(new TabPage { - var page = new TabPage - { - Name = key, - Text = text - }; - Add(page); - } + Name = key, + Text = text + }); - public void Add(string? key, string? text, int imageIndex) + public void Add(string? key, string? text, int imageIndex) => Add(new TabPage { - var page = new TabPage - { - Name = key, - Text = text, - ImageIndex = imageIndex - }; - Add(page); - } + Name = key, + Text = text, + ImageIndex = imageIndex + }); - public void Add(string? key, string? text, string imageKey) + public void Add(string? key, string? text, string imageKey) => Add(new TabPage { - var page = new TabPage - { - Name = key, - Text = text, - ImageKey = imageKey - }; - Add(page); - } + Name = key, + Text = text, + ImageKey = imageKey + }); public void AddRange(TabPage[] pages) { @@ -262,32 +246,25 @@ void IList.Insert(int index, object? tabPage) Insert(index, actualTabPage); } - public void Insert(int index, string? text) + public void Insert(int index, string? text) => Insert(index, new TabPage { - var page = new TabPage - { - Text = text - }; - Insert(index, page); - } + Text = text + }); - public void Insert(int index, string? key, string? text) + public void Insert(int index, string? key, string? text) => Insert(index, new TabPage { - var page = new TabPage - { - Name = key, - Text = text - }; - Insert(index, page); - } + Name = key, + Text = text + }); public void Insert(int index, string? key, string? text, int imageIndex) { - var page = new TabPage + TabPage page = new() { Name = key, Text = text }; + Insert(index, page); // ImageKey and ImageIndex require parenting. @@ -296,11 +273,12 @@ public void Insert(int index, string? key, string? text, int imageIndex) public void Insert(int index, string? key, string? text, string imageKey) { - var page = new TabPage + TabPage page = new() { Name = key, Text = text }; + Insert(index, page); // ImageKey and ImageIndex require parenting. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.cs index 892b5ec30c1..ce448254ce0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabControl.cs @@ -24,7 +24,7 @@ namespace System.Windows.Forms; public partial class TabControl : Control { private static readonly Size DefaultItemSize = Size.Empty; - private static readonly Point DefaultPaddingPoint = new Point(6, 3); + private static readonly Point DefaultPaddingPoint = new(6, 3); // Properties private readonly TabPageCollection _tabCollection; @@ -45,11 +45,11 @@ public partial class TabControl : Control private EventHandler? _onSelectedIndexChanged; private DrawItemEventHandler? _onDrawItem; - private static readonly object s_deselectingEvent = new object(); - private static readonly object s_deselectedEvent = new object(); - private static readonly object s_selectingEvent = new object(); - private static readonly object s_selectedEvent = new object(); - private static readonly object s_rightToLeftLayoutChangedEvent = new object(); + private static readonly object s_deselectingEvent = new(); + private static readonly object s_deselectedEvent = new(); + private static readonly object s_selectingEvent = new(); + private static readonly object s_selectedEvent = new(); + private static readonly object s_rightToLeftLayoutChangedEvent = new(); // Perf: take all the bools and put them into a state variable: see TabControlState consts above private BitVector32 _tabControlState; @@ -1111,7 +1111,7 @@ public Rectangle GetTabRect(int index) } SetState(State.GetTabRectfromItemSize, false); - RECT rect = default(RECT); + RECT rect = default; // normally, we would not want to create the handle for this, but since // it is dependent on the actual physical display, we simply must. @@ -1945,7 +1945,7 @@ private unsafe void WmReflectDrawItem(ref Message m) { DRAWITEMSTRUCT* dis = (DRAWITEMSTRUCT*)(nint)m.LParamInternal; - using var e = new DrawItemEventArgs( + using DrawItemEventArgs e = new( dis->hDC.CreateGraphics(), Font, dis->rcItem, @@ -2158,7 +2158,7 @@ private static void PrefixAmpersands(ref string value) } // Insert extra ampersands - var newString = new StringBuilder(); + StringBuilder newString = new(); newString.Append(value.AsSpan(0, firstAmpersand)); for (int i = firstAmpersand; i < value.Length; ++i) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.cs index e38b808e383..3480362faa0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TabPage.cs @@ -28,7 +28,7 @@ public partial class TabPage : Panel private bool _useVisualStyleBackColor; private List? _associatedToolTips; private ToolTip? _externalToolTip; - private readonly ToolTip _internalToolTip = new ToolTip(); + private readonly ToolTip _internalToolTip = new(); private TabAccessibleObject? _tabAccessibilityObject; /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanel.cs index 1f4a5e65e67..0216412f3bb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutPanel.cs @@ -23,7 +23,7 @@ namespace System.Windows.Forms; public class TableLayoutPanel : Panel, IExtenderProvider { private readonly TableLayoutSettings _tableLayoutSettings; - private static readonly object s_eventCellPaint = new object(); + private static readonly object s_eventCellPaint = new(); public TableLayoutPanel() { @@ -441,7 +441,7 @@ protected override void OnPaintBackground(PaintEventArgs e) if (clipRect.IntersectsWith(insideCellBounds)) { // First, call user's painting code - using (var pcea = new TableLayoutCellPaintEventArgs(e, clipRect, insideCellBounds, i, j)) + using (TableLayoutCellPaintEventArgs pcea = new(e, clipRect, insideCellBounds, i, j)) { OnCellPaint(pcea); if (!((IGraphicsHdcProvider)pcea).IsGraphicsStateClean) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.TableLayoutSettingsStub.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.TableLayoutSettingsStub.cs index 88cca7dc85c..fd3cca2f15d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.TableLayoutSettingsStub.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.TableLayoutSettingsStub.cs @@ -13,7 +13,7 @@ public sealed partial class TableLayoutSettings { private class TableLayoutSettingsStub { - private static ControlInformation s_defaultControlInfo = new ControlInformation(null, -1, -1, 1, 1); + private static ControlInformation s_defaultControlInfo = new(null, -1, -1, 1, 1); private TableLayoutColumnStyleCollection _columnStyles; private TableLayoutRowStyleCollection _rowStyles; private Dictionary _controlsInfo; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.cs index 3ad37862cb0..532eb374e92 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TableLayoutSettings.cs @@ -518,7 +518,7 @@ internal List GetControlsInformation() { if (element is Control c) { - ControlInformation controlInfo = default(ControlInformation); + ControlInformation controlInfo = default; // We need to go through the PropertyDescriptor for the Name property // since it is shadowed. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs index ac34a96b26a..10b54f126a9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialog.cs @@ -73,7 +73,7 @@ public partial class TaskDialog : IWin32Window /// notification was /// not yet received. /// - private readonly Queue _waitingNavigationPages = new Queue(); + private readonly Queue _waitingNavigationPages = new(); /// /// The of a that represents this diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButton.cs index 32989224d34..048162d4c02 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButton.cs @@ -95,7 +95,7 @@ internal TaskDialogButton(TaskDialogResult standardButtonResult) /// /// Gets a standard instance representing the OK button. /// - public static TaskDialogButton OK => new TaskDialogButton(TaskDialogResult.OK); + public static TaskDialogButton OK => new(TaskDialogResult.OK); /// /// Gets a standard instance representing the Cancel button. @@ -108,37 +108,37 @@ internal TaskDialogButton(TaskDialogResult standardButtonResult) /// ). /// /// - public static TaskDialogButton Cancel => new TaskDialogButton(TaskDialogResult.Cancel); + public static TaskDialogButton Cancel => new(TaskDialogResult.Cancel); /// /// Gets a standard instance representing the Abort button. /// - public static TaskDialogButton Abort => new TaskDialogButton(TaskDialogResult.Abort); + public static TaskDialogButton Abort => new(TaskDialogResult.Abort); /// /// Gets a standard instance representing the Retry button. /// - public static TaskDialogButton Retry => new TaskDialogButton(TaskDialogResult.Retry); + public static TaskDialogButton Retry => new(TaskDialogResult.Retry); /// /// Gets a standard instance representing the Ignore button. /// - public static TaskDialogButton Ignore => new TaskDialogButton(TaskDialogResult.Ignore); + public static TaskDialogButton Ignore => new(TaskDialogResult.Ignore); /// /// Gets a standard instance representing the Yes button. /// - public static TaskDialogButton Yes => new TaskDialogButton(TaskDialogResult.Yes); + public static TaskDialogButton Yes => new(TaskDialogResult.Yes); /// /// Gets a standard instance representing the No button. /// - public static TaskDialogButton No => new TaskDialogButton(TaskDialogResult.No); + public static TaskDialogButton No => new(TaskDialogResult.No); /// /// Gets a standard instance representing the Close button. /// - public static TaskDialogButton Close => new TaskDialogButton(TaskDialogResult.Close); + public static TaskDialogButton Close => new(TaskDialogResult.Close); /// /// Gets a standard instance representing the Help button. @@ -149,17 +149,17 @@ internal TaskDialogButton(TaskDialogResult standardButtonResult) /// event. /// /// - public static TaskDialogButton Help => new TaskDialogButton(TaskDialogResult.Help); + public static TaskDialogButton Help => new(TaskDialogResult.Help); /// /// Gets a standard instance representing the Try Again button. /// - public static TaskDialogButton TryAgain => new TaskDialogButton(TaskDialogResult.TryAgain); + public static TaskDialogButton TryAgain => new(TaskDialogResult.TryAgain); /// /// Gets a standard instance representing the Continue button. /// - public static TaskDialogButton Continue => new TaskDialogButton(TaskDialogResult.Continue); + public static TaskDialogButton Continue => new(TaskDialogResult.Continue); /// /// Gets or sets a value that indicates whether the task dialog should close diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButtonCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButtonCollection.cs index 780c0a8492e..6276c7dbb93 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButtonCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogButtonCollection.cs @@ -12,7 +12,7 @@ namespace System.Windows.Forms; public class TaskDialogButtonCollection : Collection { // HashSet to detect duplicate items. - private readonly HashSet _itemSet = new HashSet(); + private readonly HashSet _itemSet = new(); /// /// Initializes a new instance of the class. @@ -37,7 +37,7 @@ public TaskDialogButtonCollection() /// public TaskDialogButton Add(string? text, bool enabled = true, bool allowCloseDialog = true) { - var button = new TaskDialogButton(text, enabled, allowCloseDialog); + TaskDialogButton button = new(text, enabled, allowCloseDialog); Add(button); return button; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogFootnote.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogFootnote.cs index 8c5d69a7bbe..4e0b330d1c8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogFootnote.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogFootnote.cs @@ -35,7 +35,7 @@ public TaskDialogFootnote(string? text) } public static implicit operator TaskDialogFootnote(string footnoteText) - => new TaskDialogFootnote(footnoteText); + => new(footnoteText); /// /// Gets or sets the text to be displayed in the dialog's footnote area. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogIcon.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogIcon.cs index 101ea5c4321..79f2d262f8a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogIcon.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogIcon.cs @@ -35,61 +35,61 @@ public class TaskDialogIcon : IDisposable /// Gets a standard instance where the task dialog /// does not display an icon. /// - public static readonly TaskDialogIcon None = new TaskDialogIcon(TaskDialogStandardIcon.None); + public static readonly TaskDialogIcon None = new(TaskDialogStandardIcon.None); /// /// Gets a standard instance where the task dialog /// contains a symbol consisting of a lowercase letter i in a circle. /// - public static readonly TaskDialogIcon Information = new TaskDialogIcon(TaskDialogStandardIcon.Information); + public static readonly TaskDialogIcon Information = new(TaskDialogStandardIcon.Information); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an exclamation point in a triangle with a yellow background. /// - public static readonly TaskDialogIcon Warning = new TaskDialogIcon(TaskDialogStandardIcon.Warning); + public static readonly TaskDialogIcon Warning = new(TaskDialogStandardIcon.Warning); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of white X in a circle with a red background. /// - public static readonly TaskDialogIcon Error = new TaskDialogIcon(TaskDialogStandardIcon.Error); + public static readonly TaskDialogIcon Error = new(TaskDialogStandardIcon.Error); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an user account control (UAC) shield. /// - public static readonly TaskDialogIcon Shield = new TaskDialogIcon(TaskDialogStandardIcon.Shield); + public static readonly TaskDialogIcon Shield = new(TaskDialogStandardIcon.Shield); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an user account control (UAC) shield and shows a blue bar around the icon. /// - public static readonly TaskDialogIcon ShieldBlueBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldBlueBar); + public static readonly TaskDialogIcon ShieldBlueBar = new(TaskDialogStandardIcon.ShieldBlueBar); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an user account control (UAC) shield and shows a gray bar around the icon. /// - public static readonly TaskDialogIcon ShieldGrayBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldGrayBar); + public static readonly TaskDialogIcon ShieldGrayBar = new(TaskDialogStandardIcon.ShieldGrayBar); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of an exclamation point in a yellow shield and shows a yellow bar around the icon. /// - public static readonly TaskDialogIcon ShieldWarningYellowBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldWarningYellowBar); + public static readonly TaskDialogIcon ShieldWarningYellowBar = new(TaskDialogStandardIcon.ShieldWarningYellowBar); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of white X in a red shield and shows a red bar around the icon. /// - public static readonly TaskDialogIcon ShieldErrorRedBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldErrorRedBar); + public static readonly TaskDialogIcon ShieldErrorRedBar = new(TaskDialogStandardIcon.ShieldErrorRedBar); /// /// Gets a standard instance where the task dialog /// contains an icon consisting of white tick in a green shield and shows a green bar around the icon. /// - public static readonly TaskDialogIcon ShieldSuccessGreenBar = new TaskDialogIcon(TaskDialogStandardIcon.ShieldSuccessGreenBar); + public static readonly TaskDialogIcon ShieldSuccessGreenBar = new(TaskDialogStandardIcon.ShieldSuccessGreenBar); #pragma warning restore IDE1006 // Naming Styles private readonly TaskDialogStandardIcon? _standardIcon; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButtonCollection.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButtonCollection.cs index bb0174eaafa..ebe9d21a800 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButtonCollection.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogRadioButtonCollection.cs @@ -12,7 +12,7 @@ namespace System.Windows.Forms; public class TaskDialogRadioButtonCollection : Collection { // HashSet to detect duplicate items. - private readonly HashSet _itemSet = new HashSet(); + private readonly HashSet _itemSet = new(); /// /// Initializes a new instance of the class. @@ -33,7 +33,7 @@ public TaskDialogRadioButtonCollection() /// public TaskDialogRadioButton Add(string? text) { - var button = new TaskDialogRadioButton() + TaskDialogRadioButton button = new() { Text = text }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogVerificationCheckBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogVerificationCheckBox.cs index edf5a31806b..02584528dc2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogVerificationCheckBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TaskDialogVerificationCheckBox.cs @@ -40,7 +40,7 @@ public TaskDialogVerificationCheckBox(string? text, bool isChecked = false) } public static implicit operator TaskDialogVerificationCheckBox(string verificationText) - => new TaskDialogVerificationCheckBox(verificationText); + => new(verificationText); /// /// Gets or sets the text associated with this control. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.cs index 9d3d1839230..97a5f3d8c30 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBox.cs @@ -17,7 +17,7 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionTextBox))] public partial class TextBox : TextBoxBase { - private static readonly object EVENT_TEXTALIGNCHANGED = new object(); + private static readonly object EVENT_TEXTALIGNCHANGED = new(); /// /// Controls whether or not the edit box consumes/respects ENTER key @@ -967,7 +967,7 @@ protected override unsafe void WndProc(ref Message m) PInvoke.InvalidateRect(this, lpRect: null, bErase: true); // Use BeginPaint instead of GetDC to prevent flicker and support print-to-image scenarios. - using var paintScope = new PInvoke.BeginPaintScope((HWND)Handle); + using PInvoke.BeginPaintScope paintScope = new((HWND)Handle); DrawPlaceholderText(paintScope); PInvoke.ValidateRect(this, lpRect: null); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs index 3654c5abfed..35f0cf84bf7 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextBoxBase.cs @@ -39,12 +39,12 @@ public abstract partial class TextBoxBase : Control private static readonly int scrollToCaretOnHandleCreated = BitVector32.CreateMask(shortcutsEnabled); private static readonly int setSelectionOnHandleCreated = BitVector32.CreateMask(scrollToCaretOnHandleCreated); - private static readonly object EVENT_ACCEPTSTABCHANGED = new object(); - private static readonly object EVENT_BORDERSTYLECHANGED = new object(); - private static readonly object EVENT_HIDESELECTIONCHANGED = new object(); - private static readonly object EVENT_MODIFIEDCHANGED = new object(); - private static readonly object EVENT_MULTILINECHANGED = new object(); - private static readonly object EVENT_READONLYCHANGED = new object(); + private static readonly object EVENT_ACCEPTSTABCHANGED = new(); + private static readonly object EVENT_BORDERSTYLECHANGED = new(); + private static readonly object EVENT_HIDESELECTIONCHANGED = new(); + private static readonly object EVENT_MODIFIEDCHANGED = new(); + private static readonly object EVENT_MULTILINECHANGED = new(); + private static readonly object EVENT_READONLYCHANGED = new(); /// /// The current border for this edit control. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TextRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TextRenderer.cs index 48eb36a7852..0067dfedc3d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TextRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TextRenderer.cs @@ -305,7 +305,7 @@ internal static void DrawTextInternal( // This MUST come before retrieving the HDC, which locks the Graphics object FONT_QUALITY quality = FontQualityFromTextRenderingHint(dc); - using var hdc = new DeviceContextHdcScope(dc, GetApplyStateFlags(dc, flags)); + using DeviceContextHdcScope hdc = new(dc, GetApplyStateFlags(dc, flags)); DrawTextInternal(hdc, text, font, bounds, foreColor, quality, backColor, flags); } @@ -334,7 +334,7 @@ internal static void DrawTextInternal( // This MUST come before retrieving the HDC, which locks the Graphics object FONT_QUALITY quality = FontQualityFromTextRenderingHint(e.GraphicsInternal); - using var graphicsHdc = new DeviceContextHdcScope(e.GraphicsInternal, applyGraphicsState: false); + using DeviceContextHdcScope graphicsHdc = new(e.GraphicsInternal, applyGraphicsState: false); DrawTextInternal(graphicsHdc, text, font, bounds, foreColor, quality, backColor, flags); } else @@ -539,7 +539,7 @@ private static Size MeasureTextInternal( // Applying state may not impact text size measurements. Rather than risk missing some // case we'll apply as we have historically to avoid surprise regressions. - using var hdc = new DeviceContextHdcScope(dc, GetApplyStateFlags(dc, flags)); + using DeviceContextHdcScope hdc = new(dc, GetApplyStateFlags(dc, flags)); using var hfont = GdiCache.GetHFONT(font, quality, hdc); return hdc.HDC.MeasureText(text, hfont, proposedSize, flags); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ThreadExceptionDialog.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ThreadExceptionDialog.cs index 976eb091b14..1fae1a6b336 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ThreadExceptionDialog.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ThreadExceptionDialog.cs @@ -58,13 +58,13 @@ public class ThreadExceptionDialog : Form private readonly int _scaledPictureHeight = PICTUREHEIGHT; private readonly int _scaledExceptionMessageVerticalPadding = EXCEPTIONMESSAGEVERTICALPADDING; - private readonly PictureBox _pictureBox = new PictureBox(); - private readonly Label _message = new Label(); - private readonly Button _continueButton = new Button(); - private readonly Button _quitButton = new Button(); - private readonly Button _detailsButton = new Button(); - private readonly Button _helpButton = new Button(); - private readonly TextBox _details = new TextBox(); + private readonly PictureBox _pictureBox = new(); + private readonly Label _message = new(); + private readonly Button _continueButton = new(); + private readonly Button _quitButton = new(); + private readonly Button _detailsButton = new(); + private readonly Button _helpButton = new(); + private readonly TextBox _details = new(); private Bitmap? _expandImage; private Bitmap? _collapseImage; private bool _detailsVisible; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Timer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Timer.cs index 790bbec4dd4..82373e5520d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Timer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Timer.cs @@ -28,7 +28,7 @@ public class Timer : Component // Holder for the HWND that handles our Timer messages. private TimerNativeWindow? _timerWindow; - private readonly object _syncObj = new object(); + private readonly object _syncObj = new(); /// /// Initializes a new instance of the class. @@ -207,7 +207,7 @@ private bool EnsureHandle() if (HWND.IsNull) { // Create a totally vanilla invisible window just for WM_TIMER messages - var cp = new CreateParams + CreateParams cp = new() { Style = 0, ExStyle = 0, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs index d81732a9be6..b12840fc449 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs @@ -24,8 +24,8 @@ namespace System.Windows.Forms; [DefaultEvent(nameof(ItemClicked))] public partial class ToolStrip : ScrollableControl, IArrangedElement, ISupportToolStripPanel { - private static Size s_onePixel = new Size(1, 1); - internal static Point s_invalidMouseEnter = new Point(int.MaxValue, int.MaxValue); + private static Size s_onePixel = new(1, 1); + internal static Point s_invalidMouseEnter = new(int.MaxValue, int.MaxValue); private ToolStripItemCollection? _toolStripItemCollection; private ToolStripOverflowButton? _toolStripOverflowButton; @@ -63,8 +63,8 @@ public partial class ToolStrip : ScrollableControl, IArrangedElement, ISupportTo private Font? _defaultFont; private RestoreFocusMessageFilter? _restoreFocusFilter; - private static readonly Padding s_defaultPadding = new Padding(0, 0, 1, 0); - private static readonly Padding s_defaultGripMargin = new Padding(2); + private static readonly Padding s_defaultPadding = new(0, 0, 1, 0); + private static readonly Padding s_defaultGripMargin = new(2); private Padding _scaledDefaultPadding = s_defaultPadding; private Padding _scaledDefaultGripMargin = s_defaultGripMargin; @@ -74,16 +74,16 @@ public partial class ToolStrip : ScrollableControl, IArrangedElement, ISupportTo internal static int s_insertionBeamWidth = InsertionBeamWidth; - private static readonly object s_eventPaintGrip = new object(); - private static readonly object s_eventLayoutCompleted = new object(); - private static readonly object s_eventItemAdded = new object(); - private static readonly object s_eventItemRemoved = new object(); - private static readonly object s_eventLayoutStyleChanged = new object(); - private static readonly object s_eventRendererChanged = new object(); - private static readonly object s_eventItemClicked = new object(); - private static readonly object s_eventLocationChanging = new object(); - private static readonly object s_eventBeginDrag = new object(); - private static readonly object s_eventEndDrag = new object(); + private static readonly object s_eventPaintGrip = new(); + private static readonly object s_eventLayoutCompleted = new(); + private static readonly object s_eventItemAdded = new(); + private static readonly object s_eventItemRemoved = new(); + private static readonly object s_eventLayoutStyleChanged = new(); + private static readonly object s_eventRendererChanged = new(); + private static readonly object s_eventItemClicked = new(); + private static readonly object s_eventLocationChanging = new(); + private static readonly object s_eventBeginDrag = new(); + private static readonly object s_eventEndDrag = new(); private static readonly int s_propBindingContext = PropertyStore.CreateKey(); private static readonly int s_propTextDirection = PropertyStore.CreateKey(); @@ -108,17 +108,17 @@ public partial class ToolStrip : ScrollableControl, IArrangedElement, ISupportTo internal const int STATE_MENUACTIVE = 0x00008000; #if DEBUG - internal static readonly TraceSwitch s_selectionDebug = new TraceSwitch("SelectionDebug", "Debug ToolStrip Selection code"); - internal static readonly TraceSwitch s_dropTargetDebug = new TraceSwitch("DropTargetDebug", "Debug ToolStrip Drop code"); - internal static readonly TraceSwitch s_layoutDebugSwitch = new TraceSwitch("Layout debug", "Debug ToolStrip layout code"); - internal static readonly TraceSwitch s_mouseActivateDebug = new TraceSwitch("ToolStripMouseActivate", "Debug ToolStrip WM_MOUSEACTIVATE code"); - internal static readonly TraceSwitch s_mergeDebug = new TraceSwitch("ToolStripMergeDebug", "Debug toolstrip merging"); - internal static readonly TraceSwitch s_snapFocusDebug = new TraceSwitch("SnapFocus", "Debug snapping/restoration of focus"); - internal static readonly TraceSwitch s_flickerDebug = new TraceSwitch("FlickerDebug", "Debug excessive calls to Invalidate()"); - internal static readonly TraceSwitch s_itemReorderDebug = new TraceSwitch("ItemReorderDebug", "Debug excessive calls to Invalidate()"); - internal static readonly TraceSwitch s_mdiMergeDebug = new TraceSwitch("MDIMergeDebug", "Debug toolstrip MDI merging"); - internal static readonly TraceSwitch s_menuAutoExpandDebug = new TraceSwitch("MenuAutoExpand", "Debug menu auto expand"); - internal static readonly TraceSwitch s_controlTabDebug = new TraceSwitch("ControlTab", "Debug ToolStrip Control+Tab selection"); + internal static readonly TraceSwitch s_selectionDebug = new("SelectionDebug", "Debug ToolStrip Selection code"); + internal static readonly TraceSwitch s_dropTargetDebug = new("DropTargetDebug", "Debug ToolStrip Drop code"); + internal static readonly TraceSwitch s_layoutDebugSwitch = new("Layout debug", "Debug ToolStrip layout code"); + internal static readonly TraceSwitch s_mouseActivateDebug = new("ToolStripMouseActivate", "Debug ToolStrip WM_MOUSEACTIVATE code"); + internal static readonly TraceSwitch s_mergeDebug = new("ToolStripMergeDebug", "Debug toolstrip merging"); + internal static readonly TraceSwitch s_snapFocusDebug = new("SnapFocus", "Debug snapping/restoration of focus"); + internal static readonly TraceSwitch s_flickerDebug = new("FlickerDebug", "Debug excessive calls to Invalidate()"); + internal static readonly TraceSwitch s_itemReorderDebug = new("ItemReorderDebug", "Debug excessive calls to Invalidate()"); + internal static readonly TraceSwitch s_mdiMergeDebug = new("MDIMergeDebug", "Debug toolstrip MDI merging"); + internal static readonly TraceSwitch s_menuAutoExpandDebug = new("MenuAutoExpand", "Debug menu auto expand"); + internal static readonly TraceSwitch s_controlTabDebug = new("ControlTab", "Debug ToolStrip Control+Tab selection"); #else internal static readonly TraceSwitch? s_selectionDebug; internal static readonly TraceSwitch? s_dropTargetDebug; @@ -2790,7 +2790,7 @@ private protected override void PrintToMetaFileRecursive(HDC hDC, IntPtr lParam, { using Bitmap image = new Bitmap(bounds.Width, bounds.Height); using Graphics g = Graphics.FromImage(image); - using var imageHdc = new DeviceContextHdcScope(g, applyGraphicsState: false); + using DeviceContextHdcScope imageHdc = new(g, applyGraphicsState: false); // Send the actual wm_print message PInvoke.SendMessage( @@ -3690,7 +3690,7 @@ protected override void OnPaint(PaintEventArgs e) // using WindowsGraphics here because we want to preserve the clipping information. // calling GetHdc by itself does not set up the clipping info. - using (var toolStripHDC = new DeviceContextHdcScope(toolstripGraphics, ApplyGraphicsProperties.Clipping)) + using (DeviceContextHdcScope toolStripHDC = new(toolstripGraphics, ApplyGraphicsProperties.Clipping)) { // Get the cached item HDC. HDC itemHDC = ItemHdcInfo.GetCachedItemDC(toolStripHDC, bitmapSize); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.cs index 988e0097aca..ce851e49fcc 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripButton.cs @@ -16,8 +16,8 @@ public partial class ToolStripButton : ToolStripItem private const int StandardButtonWidth = 23; private int _standardButtonWidth = StandardButtonWidth; - private static readonly object s_checkedChangedEvent = new object(); - private static readonly object s_checkStateChangedEvent = new object(); + private static readonly object s_checkedChangedEvent = new(); + private static readonly object s_checkStateChangedEvent = new(); public ToolStripButton() { @@ -211,7 +211,7 @@ protected override void OnPaint(PaintEventArgs e) if ((DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) { - var rea = new ToolStripItemImageRenderEventArgs(e.Graphics, this, InternalLayout.ImageRectangle) + ToolStripItemImageRenderEventArgs rea = new(e.Graphics, this, InternalLayout.ImageRectangle) { ShiftOnPress = true }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.cs index ca4b99092ef..7f8b1732003 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripComboBox.cs @@ -13,15 +13,15 @@ namespace System.Windows.Forms; [DefaultProperty(nameof(Items))] public partial class ToolStripComboBox : ToolStripControlHost { - internal static readonly object s_eventDropDown = new object(); - internal static readonly object s_eventDropDownClosed = new object(); - internal static readonly object s_eventDropDownStyleChanged = new object(); - internal static readonly object s_eventSelectedIndexChanged = new object(); - internal static readonly object s_eventSelectionChangeCommitted = new object(); - internal static readonly object s_eventTextUpdate = new object(); - - private static readonly Padding s_dropDownPadding = new Padding(2); - private static readonly Padding s_padding = new Padding(1, 0, 1, 0); + internal static readonly object s_eventDropDown = new(); + internal static readonly object s_eventDropDownClosed = new(); + internal static readonly object s_eventDropDownStyleChanged = new(); + internal static readonly object s_eventSelectedIndexChanged = new(); + internal static readonly object s_eventSelectionChangeCommitted = new(); + internal static readonly object s_eventTextUpdate = new(); + + private static readonly Padding s_dropDownPadding = new(2); + private static readonly Padding s_padding = new(1, 0, 1, 0); private Padding _scaledDropDownPadding = s_dropDownPadding; private Padding _scaledPadding = s_padding; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanel.cs index 5c7f02c6d45..9a6e2d84665 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripContentPanel.cs @@ -19,8 +19,8 @@ public class ToolStripContentPanel : Panel private BitVector32 _state; private static readonly int s_stateLastDoubleBuffer = BitVector32.CreateMask(); - private static readonly object EventRendererChanged = new object(); - private static readonly object EventLoad = new object(); + private static readonly object EventRendererChanged = new(); + private static readonly object EventLoad = new(); public ToolStripContentPanel() { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.cs index eb003d753f3..6709252b316 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripControlHost.cs @@ -19,15 +19,15 @@ public partial class ToolStripControlHost : ToolStripItem private ContentAlignment _controlAlign = ContentAlignment.MiddleCenter; private bool _inSetVisibleCore; - internal static readonly object s_gotFocusEvent = new object(); - internal static readonly object s_lostFocusEvent = new object(); - internal static readonly object s_keyDownEvent = new object(); - internal static readonly object s_keyPressEvent = new object(); - internal static readonly object s_keyUpEvent = new object(); - internal static readonly object s_enterEvent = new object(); - internal static readonly object s_leaveEvent = new object(); - internal static readonly object s_validatedEvent = new object(); - internal static readonly object s_validatingEvent = new object(); + internal static readonly object s_gotFocusEvent = new(); + internal static readonly object s_lostFocusEvent = new(); + internal static readonly object s_keyDownEvent = new(); + internal static readonly object s_keyPressEvent = new(); + internal static readonly object s_keyUpEvent = new(); + internal static readonly object s_enterEvent = new(); + internal static readonly object s_leaveEvent = new(); + internal static readonly object s_validatedEvent = new(); + internal static readonly object s_validatingEvent = new(); /// /// Constructs a ToolStripControlHost diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.cs index c0d80f11c58..f1ee3002545 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDown.cs @@ -20,7 +20,7 @@ public partial class ToolStripDropDown : ToolStrip private bool autoSize = true; private int countDropDownItemsAssignedTo; // the number of dropdown items using this as their dropdown.. private BitVector32 state; - private Point displayLocation = new Point(0, 0); + private Point displayLocation = new(0, 0); private bool saveSourceControl; private ToolStripDropDownDirection childDropDownDirection = ToolStripDropDownDirection.Default; @@ -29,17 +29,17 @@ public partial class ToolStripDropDown : ToolStrip private static readonly int PropOpacity = PropertyStore.CreateKey(); private static readonly int PropSourceControl = PropertyStore.CreateKey(); - private static readonly object EventOpening = new object(); - private static readonly object EventOpened = new object(); - private static readonly object EventClosed = new object(); - private static readonly object EventClosing = new object(); + private static readonly object EventOpening = new(); + private static readonly object EventOpened = new(); + private static readonly object EventClosed = new(); + private static readonly object EventClosing = new(); - private static readonly Padding defaultPadding = new Padding(1, 2, 1, 2); + private static readonly Padding defaultPadding = new(1, 2, 1, 2); private Padding scaledDefaultPadding = defaultPadding; #if DEBUG - internal static TraceSwitch DropDownActivateDebug = new TraceSwitch("DropDownActivateDebug", "Debug activation code for dropDown controls"); - internal static TraceSwitch DropDownDebugBounds = new TraceSwitch("DropDownDebugBounds", "Debug GetDropDownBounds"); + internal static TraceSwitch DropDownActivateDebug = new("DropDownActivateDebug", "Debug activation code for dropDown controls"); + internal static TraceSwitch DropDownDebugBounds = new("DropDownDebugBounds", "Debug GetDropDownBounds"); #else internal static TraceSwitch? DropDownActivateDebug; internal static TraceSwitch? DropDownDebugBounds; @@ -1816,7 +1816,7 @@ protected override void SetVisibleCore(bool visible) ToolStripDropDownCloseReason reason = closeReason; ResetCloseReason(); - var e = new ToolStripDropDownClosingEventArgs(reason); + ToolStripDropDownClosingEventArgs e = new(reason); // Fire Closing Event // Cancel is prepopulated based on AutoClose feature. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItem.cs index 195471e20a2..64e3ae69eb4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownItem.cs @@ -19,11 +19,11 @@ public abstract class ToolStripDropDownItem : ToolStripItem private ToolStripDropDown? _dropDown; private ToolStripDropDownDirection _toolStripDropDownDirection = ToolStripDropDownDirection.Default; private ToolTip? _hookedKeyboardTooltip; - private static readonly object EventDropDownShow = new object(); - private static readonly object EventDropDownHide = new object(); - private static readonly object EventDropDownOpened = new object(); - private static readonly object EventDropDownClosed = new object(); - private static readonly object EventDropDownItemClicked = new object(); + private static readonly object EventDropDownShow = new(); + private static readonly object EventDropDownHide = new(); + private static readonly object EventDropDownOpened = new(); + private static readonly object EventDropDownClosed = new(); + private static readonly object EventDropDownItemClicked = new(); /// /// Protected ctor so you can't create one of these without deriving from it. @@ -775,7 +775,7 @@ internal override void ToolStrip_RescaleConstants(int oldDpi, int newDpi) // Traversing the tree of DropDownMenuItems non-recursively to set new // Font (where necessary because not inherited from parent), DeviceDpi and reset the scaling. - var itemsStack = new Stack(); + Stack itemsStack = new(); itemsStack.Push(this); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.cs index dd2d82b2ad2..4b294dd5474 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropDownMenu.cs @@ -12,10 +12,10 @@ namespace System.Windows.Forms; [Designer($"System.Windows.Forms.Design.ToolStripDropDownDesigner, {AssemblyRef.SystemDesign}")] public partial class ToolStripDropDownMenu : ToolStripDropDown { - private static readonly Padding ImagePadding = new Padding(2); - private static readonly Padding TextPadding = new Padding(8, 1, 9, 1); - private static readonly Padding CheckPadding = new Padding(5, 2, 2, 2); - private static readonly Padding ArrowPadding = new Padding(0, 0, 8, 0); + private static readonly Padding ImagePadding = new(2); + private static readonly Padding TextPadding = new(8, 1, 9, 1); + private static readonly Padding CheckPadding = new(5, 2, 2, 2); + private static readonly Padding ArrowPadding = new(0, 0, 8, 0); // This is totally a UI Fudge - if we have an image or check margin with // no image or checks in it use this - which is consistent with office @@ -45,7 +45,7 @@ public partial class ToolStripDropDownMenu : ToolStripDropDown private static readonly int stateShowCheckMargin = BitVector32.CreateMask(stateShowImageMargin); private static readonly int stateMaxItemSizeValid = BitVector32.CreateMask(stateShowCheckMargin); - private static readonly Size DefaultImageSize = new Size(16, 16); + private static readonly Size DefaultImageSize = new(16, 16); private Size _scaledDefaultImageSize = DefaultImageSize; private int _scaledDefaultImageMarginWidth = DefaultImageMarginWidth + 1; // 1px for border diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropTargetManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropTargetManager.cs index 6229b8dae5f..45df738dd71 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropTargetManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripDropTargetManager.cs @@ -23,7 +23,7 @@ internal class ToolStripDropTargetManager : IDropTarget #endif #if DEBUG - internal static readonly TraceSwitch DragDropDebug = new TraceSwitch("DragDropDebug", "Debug ToolStrip DragDrop code"); + internal static readonly TraceSwitch DragDropDebug = new("DragDropDebug", "Debug ToolStrip DragDrop code"); #else internal static readonly TraceSwitch? DragDropDebug; #endif diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.cs index 21c1de31196..842c850c2ea 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripGrip.cs @@ -15,7 +15,7 @@ internal partial class ToolStripGrip : ToolStripButton private Point _lastEndLocation = ToolStrip.s_invalidMouseEnter; private static Size s_dragSize = LayoutUtils.s_maxSize; - private static readonly Padding _defaultPadding = new Padding(2); + private static readonly Padding _defaultPadding = new(2); private const int GripThicknessDefault = 3; private const int GripThicknessVisualStylesEnabled = 5; private Padding _scaledDefaultPadding = _defaultPadding; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripHighContrastRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripHighContrastRenderer.cs index 74871d962d4..c8e03e15b08 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripHighContrastRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripHighContrastRenderer.cs @@ -444,16 +444,16 @@ private static void RenderItemInternalFilled(ToolStripItemRenderEventArgs e, boo private static void DrawHightContrastDashedBorder(Graphics graphics, ToolStripItem item) { - var bounds = item.ClientBounds; + Rectangle bounds = item.ClientBounds; float[] dashValues = { 2, 2 }; int penWidth = 2; - var focusPen1 = new Pen(SystemColors.ControlText, penWidth) + Pen focusPen1 = new(SystemColors.ControlText, penWidth) { DashPattern = dashValues }; - var focusPen2 = new Pen(SystemColors.Control, penWidth) + Pen focusPen2 = new(SystemColors.Control, penWidth) { DashPattern = dashValues, DashOffset = 2 diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.cs index 6ba64600b04..c49ea21ac00 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.ToolStripItemInternalLayout.cs @@ -18,7 +18,7 @@ internal partial class ToolStripItemInternalLayout private readonly ToolStripItem _ownerItem; private ButtonBaseAdapter.LayoutData? _layoutData; private const int BorderWidth = 2; - private static readonly Size s_invalidSize = new Size(int.MinValue, int.MinValue); + private static readonly Size s_invalidSize = new(int.MinValue, int.MinValue); private Size _lastPreferredSize = s_invalidSize; private ToolStripLayoutData? _parentLayoutData; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.cs index 7941f56faba..76f00aabbc4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.cs @@ -29,7 +29,7 @@ public abstract partial class ToolStripItem : BindableComponent, IKeyboardToolTip { #if DEBUG - internal static readonly TraceSwitch s_mouseDebugging = new TraceSwitch("MouseDebugging", "Debug ToolStripItem mouse debugging code"); + internal static readonly TraceSwitch s_mouseDebugging = new("MouseDebugging", "Debug ToolStripItem mouse debugging code"); #else internal static readonly TraceSwitch? s_mouseDebugging; #endif @@ -52,8 +52,8 @@ public abstract partial class ToolStripItem : BindableComponent, private ToolStripItemImageScaling _imageScaling = ToolStripItemImageScaling.SizeToFit; private Size _cachedTextSize; - private static readonly Padding s_defaultMargin = new Padding(0, 1, 0, 2); - private static readonly Padding s_defaultStatusStripMargin = new Padding(0, 2, 0, 0); + private static readonly Padding s_defaultMargin = new(0, 1, 0, 2); + private static readonly Padding s_defaultStatusStripMargin = new(0, 2, 0, 0); private Padding _scaledDefaultMargin = s_defaultMargin; private Padding _scaledDefaultStatusStripMargin = s_defaultStatusStripMargin; @@ -63,36 +63,36 @@ public abstract partial class ToolStripItem : BindableComponent, private Input.ICommand? _command; private object? _commandParameter; - private static readonly ArrangedElementCollection s_emptyChildCollection = new ArrangedElementCollection(); - - internal static readonly object s_mouseDownEvent = new object(); - internal static readonly object s_mouseEnterEvent = new object(); - internal static readonly object s_mouseLeaveEvent = new object(); - internal static readonly object s_mouseHoverEvent = new object(); - internal static readonly object s_mouseMoveEvent = new object(); - internal static readonly object s_mouseUpEvent = new object(); - internal static readonly object s_clickEvent = new object(); - internal static readonly object s_doubleClickEvent = new object(); - internal static readonly object s_dragDropEvent = new object(); - internal static readonly object s_dragEnterEvent = new object(); - internal static readonly object s_dragLeaveEvent = new object(); - internal static readonly object s_dragOverEvent = new object(); - internal static readonly object s_displayStyleChangedEvent = new object(); - internal static readonly object s_enabledChangedEvent = new object(); - internal static readonly object s_internalEnabledChangedEvent = new object(); - internal static readonly object s_fontChangedEvent = new object(); - internal static readonly object s_foreColorChangedEvent = new object(); - internal static readonly object s_backColorChangedEvent = new object(); - internal static readonly object s_giveFeedbackEvent = new object(); - internal static readonly object s_queryContinueDragEvent = new object(); - internal static readonly object s_queryAccessibilityHelpEvent = new object(); - internal static readonly object s_locationChangedEvent = new object(); - internal static readonly object s_rightToLeftChangedEvent = new object(); - internal static readonly object s_visibleChangedEvent = new object(); - internal static readonly object s_availableChangedEvent = new object(); - internal static readonly object s_ownerChangedEvent = new object(); - internal static readonly object s_paintEvent = new object(); - internal static readonly object s_textChangedEvent = new object(); + private static readonly ArrangedElementCollection s_emptyChildCollection = new(); + + internal static readonly object s_mouseDownEvent = new(); + internal static readonly object s_mouseEnterEvent = new(); + internal static readonly object s_mouseLeaveEvent = new(); + internal static readonly object s_mouseHoverEvent = new(); + internal static readonly object s_mouseMoveEvent = new(); + internal static readonly object s_mouseUpEvent = new(); + internal static readonly object s_clickEvent = new(); + internal static readonly object s_doubleClickEvent = new(); + internal static readonly object s_dragDropEvent = new(); + internal static readonly object s_dragEnterEvent = new(); + internal static readonly object s_dragLeaveEvent = new(); + internal static readonly object s_dragOverEvent = new(); + internal static readonly object s_displayStyleChangedEvent = new(); + internal static readonly object s_enabledChangedEvent = new(); + internal static readonly object s_internalEnabledChangedEvent = new(); + internal static readonly object s_fontChangedEvent = new(); + internal static readonly object s_foreColorChangedEvent = new(); + internal static readonly object s_backColorChangedEvent = new(); + internal static readonly object s_giveFeedbackEvent = new(); + internal static readonly object s_queryContinueDragEvent = new(); + internal static readonly object s_queryAccessibilityHelpEvent = new(); + internal static readonly object s_locationChangedEvent = new(); + internal static readonly object s_rightToLeftChangedEvent = new(); + internal static readonly object s_visibleChangedEvent = new(); + internal static readonly object s_availableChangedEvent = new(); + internal static readonly object s_ownerChangedEvent = new(); + internal static readonly object s_paintEvent = new(); + internal static readonly object s_textChangedEvent = new(); internal static readonly object s_commandChangedEvent = new(); internal static readonly object s_commandParameterChangedEvent = new(); @@ -2131,7 +2131,7 @@ protected virtual AccessibleObject CreateAccessibilityInstance() /// gets laid out in the ToolStripItem /// private protected virtual ToolStripItemInternalLayout CreateInternalLayout() - => new ToolStripItemInternalLayout(this); + => new(this); /// /// Disposes this ToolStrip item. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.cs index f888cdfec6b..b4e17258bbe 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.ModalMenuFilter.cs @@ -43,7 +43,7 @@ internal partial class ModalMenuFilter : IMessageModifyAndFilter private ToolStrip? _toplevelToolStrip; - private readonly WeakReference _lastFocusedTool = new WeakReference(null); + private readonly WeakReference _lastFocusedTool = new(null); #if DEBUG private bool _justEnteredMenuMode; @@ -571,7 +571,7 @@ public bool PreFilterMessage(ref Message m) return false; } - var activeToolStripHandle = new HandleRef(activeToolStrip); + HandleRef activeToolStripHandle = new(activeToolStrip); var activeWindowHandle = Control.GetHandleRef(PInvoke.GetActiveWindow()); // if the active window has changed... diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs index 2d20269eca4..e28d3eff9c0 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs @@ -24,7 +24,7 @@ public static partial class ToolStripManager private static bool t_initialized; private static Font s_defaultFont; - private static ConcurrentDictionary s_defaultFontCache = new ConcurrentDictionary(); + private static ConcurrentDictionary s_defaultFontCache = new(); // WARNING: When subscribing to static event handlers - make sure you unhook from them // otherwise you can leak USER objects on process shutdown. @@ -34,7 +34,7 @@ public static partial class ToolStripManager private const int StaticEventDefaultRendererChanged = 0; private const int StaticEventCount = 1; - private static readonly object s_internalSyncObject = new object(); + private static readonly object s_internalSyncObject = new(); private static void InitializeThread() { @@ -697,7 +697,7 @@ public static void SaveSettings(Form sourceForm, string key) ArgumentNullException.ThrowIfNull(sourceForm); ArgumentNullException.ThrowIfNull(key); - var settingsManager = new ToolStripSettingsManager(sourceForm, key); + ToolStripSettingsManager settingsManager = new(sourceForm, key); settingsManager.Save(); } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.cs index c3d1519a85e..ce7cc480b0e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripMenuItem.cs @@ -19,7 +19,7 @@ namespace System.Windows.Forms; $"System.ComponentModel.Design.Serialization.CodeDomSerializer, {AssemblyRef.SystemDesign}")] public partial class ToolStripMenuItem : ToolStripDropDownItem { - private static readonly MenuTimer s_menuTimer = new MenuTimer(); + private static readonly MenuTimer s_menuTimer = new(); private static readonly int s_propShortcutKeys = PropertyStore.CreateKey(); private static readonly int s_propCheckState = PropertyStore.CreateKey(); @@ -48,17 +48,17 @@ public partial class ToolStripMenuItem : ToolStripDropDownItem private string? _cachedShortcutText; private Size _cachedShortcutSize = Size.Empty; - private static readonly Padding s_defaultPadding = new Padding(4, 0, 4, 0); - private static readonly Padding s_defaultDropDownPadding = new Padding(0, 1, 0, 1); - private static readonly Size s_checkMarkBitmapSize = new Size(16, 16); + private static readonly Padding s_defaultPadding = new(4, 0, 4, 0); + private static readonly Padding s_defaultDropDownPadding = new(0, 1, 0, 1); + private static readonly Size s_checkMarkBitmapSize = new(16, 16); private Padding _scaledDefaultPadding = s_defaultPadding; private Padding _scaledDefaultDropDownPadding = s_defaultDropDownPadding; private Size _scaledCheckMarkBitmapSize = s_checkMarkBitmapSize; private byte _openMouseId; - private static readonly object s_eventCheckedChanged = new object(); - private static readonly object s_eventCheckStateChanged = new object(); + private static readonly object s_eventCheckedChanged = new(); + private static readonly object s_eventCheckStateChanged = new(); public ToolStripMenuItem() : base() diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.cs index 29de44f2ffa..63b38c6d91f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripOverflow.cs @@ -10,7 +10,7 @@ namespace System.Windows.Forms; public partial class ToolStripOverflow : ToolStripDropDown, IArrangedElement { #if DEBUG - internal static readonly TraceSwitch PopupLayoutDebug = new TraceSwitch("PopupLayoutDebug", "Debug ToolStripPopup Layout code"); + internal static readonly TraceSwitch PopupLayoutDebug = new("PopupLayoutDebug", "Debug ToolStripPopup Layout code"); #else internal static readonly TraceSwitch? PopupLayoutDebug; #endif diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs index fc35de47e34..5137417d964 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs @@ -15,16 +15,16 @@ namespace System.Windows.Forms; public partial class ToolStripPanel : ContainerControl, IArrangedElement { private Orientation _orientation = Orientation.Horizontal; - private static readonly Padding s_rowMargin = new Padding(3, 0, 0, 0); + private static readonly Padding s_rowMargin = new(3, 0, 0, 0); private Padding _scaledRowMargin = s_rowMargin; private ToolStripRendererSwitcher? _rendererSwitcher; private BitVector32 _state; private readonly ToolStripContainer? _owner; #if DEBUG - internal static TraceSwitch s_toolStripPanelDebug = new TraceSwitch("ToolStripPanelDebug", "Debug code for rafting mouse movement"); - internal static TraceSwitch s_toolStripPanelFeedbackDebug = new TraceSwitch("ToolStripPanelFeedbackDebug", "Debug code for rafting feedback"); - internal static TraceSwitch s_toolStripPanelMissingRowDebug = new TraceSwitch("ToolStripPanelMissingRowDebug", "Debug code for rafting feedback"); + internal static TraceSwitch s_toolStripPanelDebug = new("ToolStripPanelDebug", "Debug code for rafting mouse movement"); + internal static TraceSwitch s_toolStripPanelFeedbackDebug = new("ToolStripPanelFeedbackDebug", "Debug code for rafting feedback"); + internal static TraceSwitch s_toolStripPanelMissingRowDebug = new("ToolStripPanelMissingRowDebug", "Debug code for rafting feedback"); #else internal static TraceSwitch? s_toolStripPanelDebug; internal static TraceSwitch? s_toolStripPanelFeedbackDebug; @@ -41,9 +41,9 @@ public partial class ToolStripPanel : ContainerControl, IArrangedElement private static readonly int s_stateLayoutSuspended = BitVector32.CreateMask(s_stateEndInit); private static readonly int s_stateRightToLeftChanged = BitVector32.CreateMask(s_stateLayoutSuspended); - internal static readonly Padding s_dragMargin = new Padding(10); + internal static readonly Padding s_dragMargin = new(10); - private static readonly object s_eventRendererChanged = new object(); + private static readonly object s_eventRendererChanged = new(); public ToolStripPanel() { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.cs index a3149080b6b..1d4fa872432 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanelRow.cs @@ -33,7 +33,7 @@ public partial class ToolStripPanelRow : Component, IArrangedElement private static readonly int s_propControlsCollection = PropertyStore.CreateKey(); #if DEBUG - internal static TraceSwitch s_toolStripPanelRowCreationDebug = new TraceSwitch("ToolStripPanelRowCreationDebug", "Debug code for rafting row creation"); + internal static TraceSwitch s_toolStripPanelRowCreationDebug = new("ToolStripPanelRowCreationDebug", "Debug code for rafting row creation"); #else internal static TraceSwitch? s_toolStripPanelRowCreationDebug; #endif @@ -730,7 +730,7 @@ void IArrangedElement.PerformLayout(IArrangedElement container, string? property #region MouseStuff #if DEBUG - internal static readonly TraceSwitch ToolStripPanelMouseDebug = new TraceSwitch("ToolStripPanelMouse", "Debug ToolStrip WM_MOUSEACTIVATE code"); + internal static readonly TraceSwitch ToolStripPanelMouseDebug = new("ToolStripPanelMouse", "Debug ToolStrip WM_MOUSEACTIVATE code"); #else internal static readonly TraceSwitch? ToolStripPanelMouseDebug; #endif diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.cs index 43c62e36739..ce8542b6854 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripProgressBar.cs @@ -10,10 +10,10 @@ namespace System.Windows.Forms; [DefaultProperty(nameof(Value))] public partial class ToolStripProgressBar : ToolStripControlHost { - internal static readonly object EventRightToLeftLayoutChanged = new object(); + internal static readonly object EventRightToLeftLayoutChanged = new(); - private static readonly Padding defaultMargin = new Padding(1, 2, 1, 1); - private static readonly Padding defaultStatusStripMargin = new Padding(1, 3, 1, 3); + private static readonly Padding defaultMargin = new(1, 2, 1, 1); + private static readonly Padding defaultStatusStripMargin = new(1, 3, 1, 3); private Padding scaledDefaultMargin = defaultMargin; private Padding scaledDefaultStatusStripMargin = defaultStatusStripMargin; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderer.cs index 848f38230d0..128075d979d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripRenderer.cs @@ -12,27 +12,27 @@ namespace System.Windows.Forms; public abstract class ToolStripRenderer { - private static readonly object EventRenderSplitButtonBackground = new object(); - private static readonly object EventRenderItemBackground = new object(); - private static readonly object EventRenderItemImage = new object(); - private static readonly object EventRenderItemText = new object(); - private static readonly object EventRenderToolStripBackground = new object(); - private static readonly object EventRenderGrip = new object(); - private static readonly object EventRenderButtonBackground = new object(); - private static readonly object EventRenderLabelBackground = new object(); - private static readonly object EventRenderMenuItemBackground = new object(); - private static readonly object EventRenderDropDownButtonBackground = new object(); - private static readonly object EventRenderOverflowButtonBackground = new object(); - private static readonly object EventRenderImageMargin = new object(); - private static readonly object EventRenderBorder = new object(); - private static readonly object EventRenderArrow = new object(); - private static readonly object EventRenderToolStripStatusLabelBackground = new object(); - private static readonly object EventRenderSeparator = new object(); - private static readonly object EventRenderItemCheck = new object(); - private static readonly object EventRenderToolStripPanelBackground = new object(); - private static readonly object EventRenderToolStripContentPanelBackground = new object(); - - private static readonly object EventRenderStatusStripSizingGrip = new object(); + private static readonly object EventRenderSplitButtonBackground = new(); + private static readonly object EventRenderItemBackground = new(); + private static readonly object EventRenderItemImage = new(); + private static readonly object EventRenderItemText = new(); + private static readonly object EventRenderToolStripBackground = new(); + private static readonly object EventRenderGrip = new(); + private static readonly object EventRenderButtonBackground = new(); + private static readonly object EventRenderLabelBackground = new(); + private static readonly object EventRenderMenuItemBackground = new(); + private static readonly object EventRenderDropDownButtonBackground = new(); + private static readonly object EventRenderOverflowButtonBackground = new(); + private static readonly object EventRenderImageMargin = new(); + private static readonly object EventRenderBorder = new(); + private static readonly object EventRenderArrow = new(); + private static readonly object EventRenderToolStripStatusLabelBackground = new(); + private static readonly object EventRenderSeparator = new(); + private static readonly object EventRenderItemCheck = new(); + private static readonly object EventRenderToolStripPanelBackground = new(); + private static readonly object EventRenderToolStripContentPanelBackground = new(); + + private static readonly object EventRenderStatusStripSizingGrip = new(); private static ColorMatrix? s_disabledImageColorMatrix; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.cs index 47075ec2ae0..b1bd6c07699 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSeparator.cs @@ -52,7 +52,7 @@ public override ImageLayout BackgroundImageLayout /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. /// - protected override Size DefaultSize => new Size(SeparatorThickness, SeparatorThickness); + protected override Size DefaultSize => new(SeparatorThickness, SeparatorThickness); protected internal override Padding DefaultMargin => Padding.Empty; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.cs index a762a968557..fe647ceee49 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitButton.cs @@ -25,9 +25,9 @@ public partial class ToolStripSplitButton : ToolStripDropDownItem private const int DefaultDropDownWidth = 11; - private static readonly object s_eventDefaultItemChanged = new object(); - private static readonly object s_eventButtonClick = new object(); - private static readonly object s_eventButtonDoubleClick = new object(); + private static readonly object s_eventDefaultItemChanged = new(); + private static readonly object s_eventButtonClick = new(); + private static readonly object s_eventButtonDoubleClick = new(); private static bool s_isScalingInitialized; private static int s_scaledDropDownButtonWidth = DefaultDropDownWidth; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackLayout.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackLayout.cs index 4944add5a93..b656d3ef40b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackLayout.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSplitStackLayout.cs @@ -15,7 +15,7 @@ internal class ToolStripSplitStackLayout : LayoutEngine private Rectangle displayRectangle = Rectangle.Empty; #if DEBUG - internal static readonly TraceSwitch DebugLayoutTraceSwitch = new TraceSwitch("DebugLayout", "Debug ToolStrip Layout code"); + internal static readonly TraceSwitch DebugLayoutTraceSwitch = new("DebugLayout", "Debug ToolStrip Layout code"); #else internal static readonly TraceSwitch DebugLayoutTraceSwitch; #endif diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.cs index bee54a12f3d..d6586311985 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripStatusLabel.cs @@ -16,7 +16,7 @@ namespace System.Windows.Forms; [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.StatusStrip)] public partial class ToolStripStatusLabel : ToolStripLabel, IAutomationLiveRegion { - private static readonly Padding defaultMargin = new Padding(0, 3, 0, 2); + private static readonly Padding defaultMargin = new(0, 3, 0, 2); private Padding _scaledDefaultMargin = defaultMargin; private Border3DStyle _borderStyle = Border3DStyle.Flat; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControl.cs index c8abe58ece0..1fdacf88be3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.ToolStripTextBoxControl.cs @@ -232,7 +232,7 @@ private void WmNCPaint(ref Message m) // Note that GetWindowDC just calls GetDCEx with DCX_WINDOW | DCX_USESTYLE. - using var hdc = new GetDcScope(m.HWND, HRGN.Null, GET_DCX_FLAGS.DCX_WINDOW | (GET_DCX_FLAGS)0x00010000 /* DCX_USESTYLE */); + using GetDcScope hdc = new(m.HWND, HRGN.Null, GET_DCX_FLAGS.DCX_WINDOW | (GET_DCX_FLAGS)0x00010000 /* DCX_USESTYLE */); if (hdc.IsNull) { throw new Win32Exception(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.cs index 586e6f1c261..fe6741ce455 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripTextBox.cs @@ -14,16 +14,16 @@ namespace System.Windows.Forms; [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.MenuStrip | ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.ContextMenuStrip)] public partial class ToolStripTextBox : ToolStripControlHost { - internal static readonly object s_eventTextBoxTextAlignChanged = new object(); - internal static readonly object s_eventAcceptsTabChanged = new object(); - internal static readonly object s_eventBorderStyleChanged = new object(); - internal static readonly object s_eventHideSelectionChanged = new object(); - internal static readonly object s_eventReadOnlyChanged = new object(); - internal static readonly object s_eventMultilineChanged = new object(); - internal static readonly object s_eventModifiedChanged = new object(); - - private static readonly Padding s_defaultMargin = new Padding(1, 0, 1, 0); - private static readonly Padding s_defaultDropDownMargin = new Padding(1); + internal static readonly object s_eventTextBoxTextAlignChanged = new(); + internal static readonly object s_eventAcceptsTabChanged = new(); + internal static readonly object s_eventBorderStyleChanged = new(); + internal static readonly object s_eventHideSelectionChanged = new(); + internal static readonly object s_eventReadOnlyChanged = new(); + internal static readonly object s_eventMultilineChanged = new(); + internal static readonly object s_eventModifiedChanged = new(); + + private static readonly Padding s_defaultMargin = new(1, 0, 1, 0); + private static readonly Padding s_defaultDropDownMargin = new(1); private Padding _scaledDefaultMargin = s_defaultMargin; private Padding _scaledDefaultDropDownMargin = s_defaultDropDownMargin; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.cs index 04801a5e602..9b007140c1d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.cs @@ -1829,7 +1829,7 @@ private void SetTool(IWin32Window window, string? text, TipInfo.Type type, Point Control? tool = window as Control; if (tool is not null && _tools.ContainsKey(tool)) { - var toolInfo = new ToolInfoWrapper(tool); + ToolInfoWrapper toolInfo = new(tool); if (toolInfo.SendMessage(this, PInvoke.TTM_GETTOOLINFOW) != IntPtr.Zero) { TOOLTIP_FLAGS flags = TOOLTIP_FLAGS.TTF_TRACK; @@ -1990,7 +1990,7 @@ private void Reposition(Point tipPosition, Size tipSize) private HWND GetCurrentToolHwnd() { - var toolInfo = default(ToolInfoWrapper); + ToolInfoWrapper toolInfo = default; if (toolInfo.SendMessage(this, PInvoke.TTM_GETCURRENTTOOLW) != 0) { return (HWND)toolInfo.Info.hwnd; @@ -2348,7 +2348,7 @@ private unsafe void WndProc(ref Message message) case (int)PInvoke.WM_PAINT: if (OwnerDraw && !_isBalloon && !_trackPosition) { - using var paintScope = new PInvoke.BeginPaintScope((HWND)Handle); + using PInvoke.BeginPaintScope paintScope = new((HWND)Handle); Rectangle bounds = paintScope.PaintRectangle; if (bounds == Rectangle.Empty) { diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolstripProfessionalRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolstripProfessionalRenderer.cs index 7956058d950..a05010d14d2 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolstripProfessionalRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolstripProfessionalRenderer.cs @@ -19,7 +19,7 @@ public class ToolStripProfessionalRenderer : ToolStripRenderer private const int ICON_WELL_GRADIENT_WIDTH = 12; private int iconWellGradientWidth = ICON_WELL_GRADIENT_WIDTH; - private static readonly Size onePix = new Size(1, 1); + private static readonly Size onePix = new(1, 1); private bool isScalingInitialized; private const int OVERFLOW_BUTTON_WIDTH = 12; @@ -32,7 +32,7 @@ public class ToolStripProfessionalRenderer : ToolStripRenderer private int overflowArrowOffsetY = OVERFLOW_ARROW_OFFSETY; private const int DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE = 1; - private Padding scaledDropDownMenuItemPaintPadding = new Padding(DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE + 1, 0, DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE, 0); + private Padding scaledDropDownMenuItemPaintPadding = new(DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE + 1, 0, DROP_DOWN_MENU_ITEM_PAINT_PADDING_SIZE, 0); private readonly ProfessionalColorTable? professionalColorTable; private bool roundedEdges = true; private ToolStripRenderer? toolStripHighContrastRenderer; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.cs index fca3e42d39f..f454c348dd6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TrackBar.cs @@ -24,9 +24,9 @@ namespace System.Windows.Forms; [SRDescription(nameof(SR.DescriptionTrackBar))] public partial class TrackBar : Control, ISupportInitialize { - private static readonly object s_scrollEvent = new object(); - private static readonly object s_valueChangedEvent = new object(); - private static readonly object s_rightToLeftChangedEvent = new object(); + private static readonly object s_scrollEvent = new(); + private static readonly object s_valueChangedEvent = new(); + private static readonly object s_rightToLeftChangedEvent = new(); private bool _autoSize = true; private int _largeChange = 5; private int _maximum = 10; @@ -195,7 +195,7 @@ void EnableAutoTicksIfRequired() protected override ImeMode DefaultImeMode => ImeMode.Disable; - protected override Size DefaultSize => new Size(104, PreferredDimension); + protected override Size DefaultSize => new(104, PreferredDimension); /// /// This property is overridden and hidden from statement completion diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.cs index 41902d2b8d2..39045af41e9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeNode.cs @@ -112,7 +112,7 @@ internal TreeNodeImageIndexer StateImageIndexer /// public TreeNode() { - treeNodeState = default(Collections.Specialized.BitVector32); + treeNodeState = default; } internal TreeNode(TreeView treeView) : this() @@ -228,7 +228,7 @@ public Rectangle Bounds return Rectangle.Empty; } - RECT rc = default(RECT); + RECT rc = default; unsafe { *((IntPtr*)&rc.left) = Handle; } // wparam: 1=include only text, 0=include entire line @@ -251,7 +251,7 @@ internal Rectangle RowBounds get { TreeView tv = TreeView; - RECT rc = default(RECT); + RECT rc = default; unsafe { *((IntPtr*)&rc.left) = Handle; } @@ -305,7 +305,7 @@ internal unsafe bool CheckedInternal return; } - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, hItem = _handle, @@ -331,7 +331,7 @@ public bool Checked if (_handle != IntPtr.Zero && !treeView.IsDisposed) { TreeView tv = TreeView; - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, hItem = _handle, @@ -643,7 +643,7 @@ public bool IsVisible return false; } - RECT rc = default(RECT); + RECT rc = default; unsafe { *((IntPtr*)&rc.left) = Handle; } @@ -998,7 +998,7 @@ internal TVIS State return 0; } - var item = new TVITEMW + TVITEMW item = new() { hItem = Handle, mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, @@ -1810,10 +1810,11 @@ internal unsafe void Realize(bool insertFirst) throw new InvalidOperationException(SR.InvalidCrossThreadControlCall); } - var tvis = new TVINSERTSTRUCTW + TVINSERTSTRUCTW tvis = new() { hParent = parent._handle }; + tvis.item.mask = InsertMask; TreeNode prev = PrevNode; @@ -2009,7 +2010,7 @@ private unsafe void ResetExpandedState(TreeView tv) { Debug.Assert(tv.IsHandleCreated, "nonexistent handle"); - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, hItem = _handle, @@ -2125,11 +2126,12 @@ private void UpdateNode(TVITEM_MASK mask) return; } - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | mask, hItem = _handle }; + if ((mask & TVITEM_MASK.TVIF_TEXT) != 0) { item.pszText = Marshal.StringToHGlobalAuto(text); @@ -2138,15 +2140,15 @@ private void UpdateNode(TVITEM_MASK mask) if ((mask & TVITEM_MASK.TVIF_IMAGE) != 0) { item.iImage = IsSpecialImageIndex(ImageIndexer.ActualIndex) - ? tv.ImageIndexer.ActualIndex - : ImageIndexer.ActualIndex; + ? tv.ImageIndexer.ActualIndex + : ImageIndexer.ActualIndex; } if ((mask & TVITEM_MASK.TVIF_SELECTEDIMAGE) != 0) { item.iSelectedImage = IsSpecialImageIndex(SelectedImageIndexer.ActualIndex) - ? tv.SelectedImageIndexer.ActualIndex - : SelectedImageIndexer.ActualIndex; + ? tv.SelectedImageIndexer.ActualIndex + : SelectedImageIndexer.ActualIndex; } if ((mask & TVITEM_MASK.TVIF_STATE) != 0) @@ -2191,7 +2193,7 @@ internal unsafe void UpdateImage() return; } - var item = new TVITEMW + TVITEMW item = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_IMAGE, hItem = Handle, diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.cs index 67b9d11c2b5..a72fbc2166e 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/TreeView.cs @@ -1741,7 +1741,7 @@ public TreeViewHitTestInfo HitTest(Point pt) /// public TreeViewHitTestInfo HitTest(int x, int y) { - var tvhi = new TVHITTESTINFO + TVHITTESTINFO tvhi = new() { pt = new Point(x, y) }; @@ -1788,7 +1788,7 @@ public TreeNode GetNodeAt(Point pt) /// public TreeNode GetNodeAt(int x, int y) { - var tvhi = new TVHITTESTINFO + TVHITTESTINFO tvhi = new() { pt = new Point(x, y) }; @@ -2164,7 +2164,7 @@ protected override void OnMouseHover(EventArgs e) { // Hover events need to be caught for each node within the TreeView so // the appropriate NodeHovered event can be raised. - var tvhip = new TVHITTESTINFO + TVHITTESTINFO tvhip = new() { pt = PointToClient(Cursor.Position) }; @@ -2661,7 +2661,7 @@ private unsafe void TvnSelected(NMTREEVIEW* nmtv) } // TreeView doesn't properly revert back to the unselected image if the unselected image is blank. - var rc = default(RECT); + RECT rc = default; *((IntPtr*)&rc.left) = nmtv->itemOld.hItem; if (nmtv->itemOld.hItem != IntPtr.Zero) { @@ -3008,7 +3008,7 @@ internal override unsafe ComCtl32.ToolInfoWrapper GetToolInfoWrapper(TO // The second condition is necessary for the correct display of the keyboard tooltip, // since the logic of the external tooltip blocks its display bool isExternalTooltip = ShowNodeToolTips && tooltip != KeyboardToolTip; - var wrapper = new ComCtl32.ToolInfoWrapper(this, flags, isExternalTooltip ? null : caption); + ComCtl32.ToolInfoWrapper wrapper = new(this, flags, isExternalTooltip ? null : caption); if (isExternalTooltip) wrapper.Info.lpszText = (char*)(-1); @@ -3020,7 +3020,7 @@ private unsafe bool WmShowToolTip(ref Message m) NMHDR* nmhdr = (NMHDR*)(nint)m.LParamInternal; HWND tooltipHandle = nmhdr->hwndFrom; - var tvhip = new TVHITTESTINFO + TVHITTESTINFO tvhip = new() { pt = PointToClient(Cursor.Position) }; @@ -3051,7 +3051,7 @@ private unsafe void WmNeedText(ref Message m) NMTTDISPINFOW* ttt = (NMTTDISPINFOW*)(nint)m.LParamInternal; string tipText = controlToolTipText; - var tvhip = new TVHITTESTINFO + TVHITTESTINFO tvhip = new() { pt = PointToClient(Cursor.Position) }; @@ -3128,7 +3128,7 @@ private unsafe void WmNotify(ref Message m) case (int)NM.RCLICK: MouseButtons button = MouseButtons.Left; Point pos = PointToClient(Cursor.Position); - var tvhip = new TVHITTESTINFO + TVHITTESTINFO tvhip = new() { pt = pos }; @@ -3297,7 +3297,7 @@ protected override unsafe void WndProc(ref Message m) // Check for invalid node handle if (item->hItem != IntPtr.Zero) { - var item1 = new TVITEMW + TVITEMW item1 = new() { mask = TVITEM_MASK.TVIF_HANDLE | TVITEM_MASK.TVIF_STATE, hItem = item->hItem, @@ -3368,7 +3368,7 @@ protected override unsafe void WndProc(ref Message m) // Always reset the MouseupFired. treeViewState[TREEVIEWSTATE_mouseUpFired] = false; - var tvhip = new TVHITTESTINFO + TVHITTESTINFO tvhip = new() { pt = PARAM.ToPoint(m.LParamInternal) }; @@ -3405,7 +3405,7 @@ protected override unsafe void WndProc(ref Message m) case PInvoke.WM_RBUTTONUP: Point point = PARAM.ToPoint(m.LParamInternal); - var tvhi = new TVHITTESTINFO + TVHITTESTINFO tvhi = new() { pt = point }; @@ -3486,7 +3486,7 @@ protected override unsafe void WndProc(ref Message m) treeViewState[TREEVIEWSTATE_mouseUpFired] = false; //Cache the hit-tested node for verification when mouse up is fired - var tvhit = new TVHITTESTINFO + TVHITTESTINFO tvhit = new() { pt = PARAM.ToPoint(m.LParamInternal) }; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.cs index 5552d4fd0a3..6dcf9cff207 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.UpDownButtons.cs @@ -258,7 +258,7 @@ protected override void OnPaint(PaintEventArgs e) // Draw the up and down buttons if (Application.RenderWithVisualStyles) { - var vsr = new VisualStyleRenderer(_mouseOver == ButtonID.Up + VisualStyleRenderer vsr = new(_mouseOver == ButtonID.Up ? VisualStyleElement.Spin.Up.Hot : VisualStyleElement.Spin.Up.Normal); @@ -271,7 +271,7 @@ protected override void OnPaint(PaintEventArgs e) vsr.SetParameters(VisualStyleElement.Spin.Up.Pressed); } - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); vsr.DrawBackground( hdc, new Rectangle(0, 0, _parent._defaultButtonsWidth, half_height), diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.cs index fa68b0f93ff..5068af63e92 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UpDownBase.cs @@ -242,7 +242,7 @@ protected override CreateParams CreateParams /// Deriving classes can override this to configure a default size for their control. /// This is more efficient than setting the size in the control's constructor. /// - protected override Size DefaultSize => new Size(DefaultControlWidth, PreferredHeight); + protected override Size DefaultSize => new(DefaultControlWidth, PreferredHeight); [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)] @@ -536,7 +536,7 @@ protected override void OnPaint(PaintEventArgs e) clipRight.Intersect(clipBounds); clipBottom.Intersect(clipBounds); - using var hdc = new DeviceContextHdcScope(e); + using DeviceContextHdcScope hdc = new(e); vsr.DrawBackground(hdc, bounds, clipLeft, HWNDInternal); vsr.DrawBackground(hdc, bounds, clipTop, HWNDInternal); vsr.DrawBackground(hdc, bounds, clipRight, HWNDInternal); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/UserControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/UserControl.cs index dda7c403803..75f8cfaafb4 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/UserControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/UserControl.cs @@ -20,7 +20,7 @@ namespace System.Windows.Forms; [DefaultEvent(nameof(Load))] public class UserControl : ContainerControl { - private static readonly object EVENT_LOAD = new object(); + private static readonly object EVENT_LOAD = new(); private BorderStyle _borderStyle = BorderStyle.None; /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleRenderer.cs b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleRenderer.cs index 18489e0b6b1..90387bf6a7b 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleRenderer.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/VisualStyles/VisualStyleRenderer.cs @@ -104,7 +104,7 @@ internal static bool IsCombinationDefined(string className, int part) // If the combo isn't defined, check the validity of our theme handle cache. if (!result) { - using var handle = new PInvoke.OpenThemeDataScope(HWND.Null, className); + using PInvoke.OpenThemeDataScope handle = new(HWND.Null, className); if (!handle.IsNull) { @@ -213,7 +213,7 @@ public void DrawBackground(IDeviceContext dc, Rectangle bounds) { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); DrawBackground(hdc, bounds, HWND.Null); } @@ -242,7 +242,7 @@ public void DrawBackground(IDeviceContext dc, Rectangle bounds, Rectangle clipRe { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); DrawBackground(hdc, bounds, clipRectangle, HWND.Null); } @@ -269,7 +269,7 @@ public Rectangle DrawEdge(IDeviceContext dc, Rectangle bounds, Edges edges, Edge { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); return DrawEdge(hdc, bounds, edges, style, effects); } @@ -345,7 +345,7 @@ public void DrawParentBackground(IDeviceContext dc, Rectangle bounds, Control ch if (childControl.IsHandleCreated) { - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.DrawThemeParentBackground(childControl.HWND, hdc, bounds); } } @@ -373,7 +373,7 @@ public void DrawText(IDeviceContext dc, Rectangle bounds, string? textToDraw, bo { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); DrawText(hdc, bounds, textToDraw, drawDisabled, flags); } @@ -407,7 +407,7 @@ public Rectangle GetBackgroundContentRectangle(IDeviceContext dc, Rectangle boun { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); return GetBackgroundContentRectangle(hdc, bounds); } @@ -434,7 +434,7 @@ public Rectangle GetBackgroundExtent(IDeviceContext dc, Rectangle contentBounds) return Rectangle.Empty; } - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeBackgroundExtent(HTHEME, hdc, Part, State, contentBounds, out RECT extents); return extents; } @@ -573,7 +573,7 @@ public Size GetPartSize(IDeviceContext dc, ThemeSizeType type) { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); return GetPartSize(hdc, type, HWND.Null); } @@ -603,7 +603,7 @@ public unsafe Size GetPartSize(IDeviceContext dc, Rectangle bounds, ThemeSizeTyp // Valid values are 0x0 to 0x2 SourceGenerated.EnumValidator.Validate(type, nameof(type)); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemePartSize(HTHEME, hdc, Part, State, bounds, (THEMESIZE)type, out SIZE size); return size; } @@ -630,7 +630,7 @@ public unsafe Padding GetMargins(IDeviceContext dc, MarginProperty prop) // Valid values are 0xe11 to 0xe13 SourceGenerated.EnumValidator.Validate(prop, nameof(prop)); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeMargins(HTHEME, hdc, Part, State, (THEME_PROPERTY_SYMBOL_ID)prop, null, out MARGINS margins); return new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight); @@ -661,7 +661,7 @@ public unsafe Rectangle GetTextExtent(IDeviceContext dc, string textToDraw, Text ArgumentNullException.ThrowIfNull(dc); textToDraw.ThrowIfNullOrEmpty(); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeTextExtent( HTHEME, hdc, @@ -684,7 +684,7 @@ public unsafe Rectangle GetTextExtent(IDeviceContext dc, Rectangle bounds, strin ArgumentNullException.ThrowIfNull(dc); textToDraw.ThrowIfNullOrEmpty(); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeTextExtent( HTHEME, hdc, @@ -706,7 +706,7 @@ public TextMetrics GetTextMetrics(IDeviceContext dc) { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.GetThemeTextMetrics(HTHEME, hdc, Part, State, out TEXTMETRICW tm); return TextMetrics.FromTEXTMETRICW(tm); } @@ -718,7 +718,7 @@ public HitTestCode HitTestBackground(IDeviceContext dc, Rectangle backgroundRect { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.HitTestThemeBackground( HTHEME, hdc, @@ -752,7 +752,7 @@ public HitTestCode HitTestBackground(IDeviceContext dc, Rectangle backgroundRect { ArgumentNullException.ThrowIfNull(dc); - using var hdc = new DeviceContextHdcScope(dc); + using DeviceContextHdcScope hdc = new(dc); _lastHResult = PInvoke.HitTestThemeBackground( HTHEME, hdc, @@ -865,7 +865,7 @@ private static HTHEME GetHandle(string className, bool throwExceptionOnFail) private static PInvoke.OpenThemeDataScope OpenThemeData(HWND hwnd, string classList) { - var htheme = new PInvoke.OpenThemeDataScope(hwnd, classList); + PInvoke.OpenThemeDataScope htheme = new(hwnd, classList); return htheme.IsNull ? throw new InvalidOperationException(SR.VisualStyleHandleCreationFailed) : htheme; } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.cs index 4767f4776c5..92992286738 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowser.cs @@ -301,7 +301,7 @@ public string DocumentText return string.Empty; } - using var reader = new StreamReader(stream); + using StreamReader reader = new(stream); stream.Position = 0; return reader.ReadToEnd().TrimEnd('\0'); } @@ -1067,7 +1067,7 @@ protected override void Dispose(bool disposing) /// /// Overrides the default size property of Control to specify a bigger default size of 250 x 250. /// - protected override Size DefaultSize => new Size(250, 250); + protected override Size DefaultSize => new(250, 250); /// /// Retrieves IWebBrowser2 from the native object. Overriding classes should first call base.AttachInterfaces. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.cs index b3058ec05d1..722c8945020 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserBase.cs @@ -1104,7 +1104,7 @@ private void OnNewSelection(object? sender, EventArgs e) private unsafe Size SetExtent(int width, int height) { - var sz = new Size(width, height); + Size sz = new(width, height); bool resetExtents = DesignMode; Pixel2hiMetric(ref sz); HRESULT hr = _axOleObject!.SetExtent(DVASPECT.DVASPECT_CONTENT, (SIZE*)&sz); @@ -1219,7 +1219,7 @@ private void AmbientChanged(int dispid) // Overridden properties: // - protected override Size DefaultSize => new Size(75, 23); + protected override Size DefaultSize => new(75, 23); // // Overridden methods: diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.cs index bd0ccf38007..dabc77a15cb 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserHelper.cs @@ -37,9 +37,9 @@ internal static partial class WebBrowserHelper private const int HMperInch = 2540; // Special guids - internal static Guid windowsMediaPlayer_Clsid = new Guid("{22d6f312-b0f6-11d0-94ab-0080c74c7e95}"); - internal static Guid comctlImageCombo_Clsid = new Guid("{a98a24c0-b06f-3684-8c12-c52ae341e0bc}"); - internal static Guid maskEdit_Clsid = new Guid("{c932ba85-4374-101b-a56c-00aa003668dc}"); + internal static Guid windowsMediaPlayer_Clsid = new("{22d6f312-b0f6-11d0-94ab-0080c74c7e95}"); + internal static Guid comctlImageCombo_Clsid = new("{a98a24c0-b06f-3684-8c12-c52ae341e0bc}"); + internal static Guid maskEdit_Clsid = new("{c932ba85-4374-101b-a56c-00aa003668dc}"); // Window message to check if we have already sub-classed internal static readonly MessageId REGMSG_MSG = PInvoke.RegisterWindowMessage($"{Application.WindowMessagesVersion}_subclassCheck"); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserSiteBase.cs b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserSiteBase.cs index 1a2196c168e..fa1ad3ccd19 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserSiteBase.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/WebBrowserSiteBase.cs @@ -409,8 +409,8 @@ private unsafe HRESULT OnActiveXRectChange(RECT* lprcPosRect) return HRESULT.E_INVALIDARG; } - var posRect = new RECT(0, 0, lprcPosRect->right - lprcPosRect->left, lprcPosRect->bottom - lprcPosRect->top); - var clipRect = WebBrowserHelper.GetClipRect(); + RECT posRect = new(0, 0, lprcPosRect->right - lprcPosRect->left, lprcPosRect->bottom - lprcPosRect->top); + RECT clipRect = WebBrowserHelper.GetClipRect(); Host.AXInPlaceObject!.SetObjectRects(&posRect, &clipRect); Host.MakeDirty(); return HRESULT.S_OK; diff --git a/src/System.Windows.Forms/src/misc/InvariantComparer.cs b/src/System.Windows.Forms/src/misc/InvariantComparer.cs index a0b4c08d8bd..fd8130d7233 100644 --- a/src/System.Windows.Forms/src/misc/InvariantComparer.cs +++ b/src/System.Windows.Forms/src/misc/InvariantComparer.cs @@ -10,7 +10,7 @@ namespace System; internal class InvariantComparer : IComparer { private readonly CompareInfo m_compareInfo; - internal static readonly InvariantComparer Default = new InvariantComparer(); + internal static readonly InvariantComparer Default = new(); internal InvariantComparer() { diff --git a/src/System.Windows.Forms/tests/AccessibilityTests/DataBindingExample.cs b/src/System.Windows.Forms/tests/AccessibilityTests/DataBindingExample.cs index 8cd5ad3bc20..e38c6525164 100644 --- a/src/System.Windows.Forms/tests/AccessibilityTests/DataBindingExample.cs +++ b/src/System.Windows.Forms/tests/AccessibilityTests/DataBindingExample.cs @@ -9,8 +9,8 @@ namespace Accessibility_Core_App; public partial class DataBindingExample : Form { - private readonly List _studentA = new List(); - private readonly List _studentB = new List(); + private readonly List _studentA = new(); + private readonly List _studentB = new(); public DataBindingExample() { diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs index 270fdc74444..48574a235ee 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs @@ -11,7 +11,7 @@ public partial class MainForm : Form { ISelectionService _selectionService; - private List _listOfDesignSurface = new List(); + private List _listOfDesignSurface = new(); public MainForm() { diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DesignSurfaceExt/UndoEngineExt.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DesignSurfaceExt/UndoEngineExt.cs index e0c302acec8..84b8829201b 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DesignSurfaceExt/UndoEngineExt.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DesignSurfaceExt/UndoEngineExt.cs @@ -4,8 +4,8 @@ namespace DesignSurfaceExt; public class UndoEngineExt : UndoEngine { - private Stack undoStack = new Stack(); - private Stack redoStack = new Stack(); + private Stack undoStack = new(); + private Stack redoStack = new(); public UndoEngineExt(IServiceProvider provider) : base(provider) { } diff --git a/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests.Common/TestDataSources.cs b/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests.Common/TestDataSources.cs index 70fe1c03b98..0c54485f4ad 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests.Common/TestDataSources.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests.Common/TestDataSources.cs @@ -7,7 +7,7 @@ namespace System.Windows.Forms.IntegrationTests.Common; public static class TestDataSources { public static List GetPersons() - => new List() + => new() { new Person(1, "Name 1"), new Person(2, "Name 2"), diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ScreenshotService.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ScreenshotService.cs index c5331eede1e..e9005013d50 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ScreenshotService.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ScreenshotService.cs @@ -9,7 +9,7 @@ namespace System.Windows.Forms.UITests; internal static class ScreenshotService { - private static readonly object Gate = new object(); + private static readonly object Gate = new(); /// /// Takes a picture of the screen and saves it to the location specified by diff --git a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/CollectionEditors.cs b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/CollectionEditors.cs index 8c57475a8cd..c978413761c 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/CollectionEditors.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/CollectionEditors.cs @@ -15,8 +15,8 @@ namespace WinformsControlsTest.UserControls; internal partial class CollectionEditors : Form { private string[] _stringArray = new[] { "Lorem ipsum dolor sit amet", "id quo accusamus definitionem", "graeco salutandi sed te", "mei in solum primis definitionem." }; - private List _stringList = new List { "Lorem ipsum dolor sit amet", "id quo accusamus definitionem", "graeco salutandi sed te", "mei in solum primis definitionem." }; - private Collection _stringCollection = new Collection { "Lorem ipsum dolor sit amet", "id quo accusamus definitionem", "graeco salutandi sed te", "mei in solum primis definitionem." }; + private List _stringList = new() { "Lorem ipsum dolor sit amet", "id quo accusamus definitionem", "graeco salutandi sed te", "mei in solum primis definitionem." }; + private Collection _stringCollection = new() { "Lorem ipsum dolor sit amet", "id quo accusamus definitionem", "graeco salutandi sed te", "mei in solum primis definitionem." }; public CollectionEditors() { diff --git a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/DataGridViewInVirtualModeTest.cs b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/DataGridViewInVirtualModeTest.cs index f4feb1bb5e2..dbeefaf21cf 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/DataGridViewInVirtualModeTest.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/DataGridViewInVirtualModeTest.cs @@ -10,7 +10,7 @@ public partial class DataGridViewInVirtualModeTest : Form // The example was taken from: https://docs.microsoft.com/dotnet/desktop/winforms/controls/implementing-virtual-mode-wf-datagridview-control // Declare a List to serve as the test data source - private readonly List _customers = new List(); + private readonly List _customers = new(); // Declare a TestCustomer object to store data for a row being edited private TestCustomer _customerInEdit; diff --git a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/MessageBoxes.cs b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/MessageBoxes.cs index ac59c3f137b..01230ed8720 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/MessageBoxes.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/MessageBoxes.cs @@ -9,7 +9,7 @@ namespace WinformsControlsTest; public partial class MessageBoxes : Form { private readonly ToolStripButton _btnOpen; - private readonly MessageBoxProxy _messgageBoxProxy = new MessageBoxProxy(); + private readonly MessageBoxProxy _messgageBoxProxy = new(); public MessageBoxes() { diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AxHost.ConnectionPointCookieTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AxHost.ConnectionPointCookieTests.cs index 13d7646658c..e4685d03ce8 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AxHost.ConnectionPointCookieTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/AxHost.ConnectionPointCookieTests.cs @@ -10,7 +10,7 @@ namespace System.Windows.Forms.Tests; [Collection("Sequential")] // workaround for WebBrowser control corrupting memory when run on multiple UI threads (instantiated via GUID) public class AxHostConnectionPointCookieTests { - private static readonly Guid CLSID_WebBrowser = new Guid("8856f961-340a-11d0-a96b-00c04fd705a2"); + private static readonly Guid CLSID_WebBrowser = new("8856f961-340a-11d0-a96b-00c04fd705a2"); [WinFormsFact] public void ConnectionPointCookie_Ctor_Object_Object_Type() diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/BindingSourceTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/BindingSourceTests.cs index 2eea7406f28..b8f36e049ce 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/BindingSourceTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/BindingSourceTests.cs @@ -726,7 +726,7 @@ private class SynchronizedList : VirtualList private class VirtualList : IList { - private readonly List _innerList = new List(); + private readonly List _innerList = new(); public VirtualList() { diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs index f36860d8d68..118f4f45907 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs @@ -15,7 +15,7 @@ namespace System.Windows.Forms.Tests.ComponentModel.Com2Interop; public unsafe class COM2FontConverterTests { - private static readonly Com2PropertyDescriptor s_stubDescriptor = new Com2PropertyDescriptor( + private static readonly Com2PropertyDescriptor s_stubDescriptor = new( default, "Foo", Array.Empty(), diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Handlers.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Handlers.cs index a0c50c2a163..079d930bf18 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Handlers.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Handlers.cs @@ -4748,7 +4748,7 @@ public void Control_OnPrint_InvokeSetTextInPrint_CachesText() int printCallCount = 0; control.Paint += (sender, e) => { - string longString = new string('a', 65536); + string longString = new('a', 65536); control.Text = longString; Assert.Equal(longString, control.Text); printCallCount++; diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Methods.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Methods.cs index 2b7272539f6..99f7e7c322e 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Methods.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Methods.cs @@ -4973,7 +4973,7 @@ public void Control_PerformLayout_InvokeSetTextInLayout_CachesText() int layoutCallCount = 0; control.Layout += (sender, e) => { - string longString = new string('a', 65536); + string longString = new('a', 65536); control.Text = longString; Assert.Equal(longString, control.Text); layoutCallCount++; @@ -5247,7 +5247,7 @@ public void Control_PerformLayout_InvokeControlStringSetTextInLayout_CachesText( int layoutCallCount = 0; control.Layout += (sender, e) => { - string longString = new string('a', 65536); + string longString = new('a', 65536); control.Text = longString; Assert.Equal(longString, control.Text); layoutCallCount++; diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Properties.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Properties.cs index f4ed39420a8..f78bdf82df8 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Properties.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ControlTests.Properties.cs @@ -3283,17 +3283,17 @@ public void Control_ClientSize_Get_ReturnsExpected(Control control, Size expecte private class NonZeroWidthBorderedControl : BorderedControl { - protected override Size DefaultSize => new Size(10, 0); + protected override Size DefaultSize => new(10, 0); } private class NonZeroHeightBorderedControl : BorderedControl { - protected override Size DefaultSize => new Size(0, 10); + protected override Size DefaultSize => new(0, 10); } private class NonZeroWidthNonZeroHeightBorderedControl : BorderedControl { - protected override Size DefaultSize => new Size(10, 20); + protected override Size DefaultSize => new(10, 20); } public static IEnumerable ClientSize_Set_TestData() @@ -7671,7 +7671,7 @@ public void Control_Margin_GetWithCustomDefaultMargin_ReturnsExpected(Control co private class NonZeroDefaultMarginControl : Control { - protected override Padding DefaultMargin => new Padding(1, 2, 3, 4); + protected override Padding DefaultMargin => new(1, 2, 3, 4); } private class ZeroDefaultMarginControl : Control @@ -7880,17 +7880,17 @@ public void Control_MaximumSize_GetWithCustomDefaultMaximumSize_ReturnsExpected( private class NonZeroWidthDefaultMaximumSizeControl : Control { - protected override Size DefaultMaximumSize => new Size(10, 0); + protected override Size DefaultMaximumSize => new(10, 0); } private class NonZeroHeightDefaultMaximumSizeControl : Control { - protected override Size DefaultMaximumSize => new Size(0, 20); + protected override Size DefaultMaximumSize => new(0, 20); } private class NonZeroWidthNonZeroHeightDefaultMaximumSizeControl : Control { - protected override Size DefaultMaximumSize => new Size(10, 20); + protected override Size DefaultMaximumSize => new(10, 20); } public static IEnumerable MaximumSize_Set_TestData() @@ -8489,17 +8489,17 @@ public void Control_MinimumSize_GetWithCustomDefaultMinimumSize_ReturnsExpected( private class NonZeroWidthDefaultMinimumSizeControl : Control { - protected override Size DefaultMinimumSize => new Size(10, 0); + protected override Size DefaultMinimumSize => new(10, 0); } private class NonZeroHeightDefaultMinimumSizeControl : Control { - protected override Size DefaultMinimumSize => new Size(0, 20); + protected override Size DefaultMinimumSize => new(0, 20); } private class NonZeroWidthNonZeroHeightDefaultMinimumSizeControl : Control { - protected override Size DefaultMinimumSize => new Size(10, 20); + protected override Size DefaultMinimumSize => new(10, 20); } public static IEnumerable MinimumSize_Set_TestData() @@ -9382,7 +9382,7 @@ public void Control_Padding_GetWithCustomDefaultPadding_ReturnsExpected(Control private class NonZeroDefaultPaddingControl : Control { - protected override Padding DefaultPadding => new Padding(1, 2, 3, 4); + protected override Padding DefaultPadding => new(1, 2, 3, 4); } public static IEnumerable Padding_Set_TestData() diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/FeatureSupportTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/FeatureSupportTests.cs index d69c205af03..c6c12ffc6af 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/FeatureSupportTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/FeatureSupportTests.cs @@ -182,21 +182,21 @@ public Version GetVersionPresent(object feature) return new Version(1, 2, 3, 4); } - public object _field = new object(); - public static object s_field = new object(); + public object _field = new(); + public static object s_field = new(); - public static object s_zeroVersionField = new object(); - public static object s_nonZeroVersionField = new object(); + public static object s_zeroVersionField = new(); + public static object s_nonZeroVersionField = new(); #pragma warning disable CA1823 // Unused field - private readonly object _privateField = new object(); - private static readonly object s_privateField = new object(); + private readonly object _privateField = new(); + private static readonly object s_privateField = new(); #pragma warning restore CA1823 // Unused field } private class NonIFeatureSupportClass { - public object _field = new object(); - public static object s_field = new object(); + public object _field = new(); + public static object s_field = new(); } } diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/PropertyGridViewTests.Rendering.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/PropertyGridViewTests.Rendering.cs index 2248510902f..eb0bca30f57 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/PropertyGridViewTests.Rendering.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/PropertyGridViewTests.Rendering.cs @@ -13,7 +13,7 @@ public partial class PropertyGridViewTests [WinFormsFact] public void PropertyGridView_Render_Labels_Values_Correctly() { - Point pt = default(Point); + Point pt = default; using PropertyGrid propertyGrid = new() { SelectedObject = pt, diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/TestAccessors.PropertyGridTestAccessor.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/TestAccessors.PropertyGridTestAccessor.cs index bdcb5b479ed..bfa1d39cef2 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/TestAccessors.PropertyGridTestAccessor.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/TestAccessors.PropertyGridTestAccessor.cs @@ -20,5 +20,5 @@ public PropertyGridTestAccessor(Windows.Forms.PropertyGrid instance) : base(inst } public static PropertyGridTestAccessor TestAccessor(this Windows.Forms.PropertyGrid propertyGrid) - => new PropertyGridTestAccessor(propertyGrid); + => new(propertyGrid); } diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/TestAccessors.PropertyGridViewTestAccessor.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/TestAccessors.PropertyGridViewTestAccessor.cs index 5a892c1554c..10fb81ace55 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/TestAccessors.PropertyGridViewTestAccessor.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/PropertyGridInternal/TestAccessors.PropertyGridViewTestAccessor.cs @@ -18,5 +18,5 @@ internal Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry Selected } internal static PropertyGridViewTestAccessor TestAccessor(this Windows.Forms.PropertyGridInternal.PropertyGridView propertyGridView) - => new PropertyGridViewTestAccessor(propertyGridView); + => new(propertyGridView); } diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ScrollableControlTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ScrollableControlTests.cs index 96107f9489d..68a137b1c24 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ScrollableControlTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ScrollableControlTests.cs @@ -1661,11 +1661,11 @@ public static IEnumerable OnPaintBackground_VisualStyles_on_WithParent } } - static Control CreateControl() => new Control + static Control CreateControl() => new() { Bounds = new Rectangle(1, 2, 30, 40) }; - static TabPage CreateTabPage() => new TabPage + static TabPage CreateTabPage() => new() { Bounds = new Rectangle(1, 2, 30, 40) }; @@ -2548,14 +2548,14 @@ public void ScrollableControl_ScrollControlIntoView_Invoke_Success(bool autoScro private class LargeControl : Control { - protected override Size DefaultSize => new Size(100, 150); + protected override Size DefaultSize => new(100, 150); - public Rectangle ExpectedSize => new Rectangle(new Point(0, 0), DefaultSize); + public Rectangle ExpectedSize => new(new Point(0, 0), DefaultSize); } private class SmallControl : Control { - protected override Size DefaultSize => new Size(50, 60); + protected override Size DefaultSize => new(50, 60); } public class SubScrollableControl : ScrollableControl diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/StatusStripTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/StatusStripTests.cs index 0df085c89ae..9ca9027bd63 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/StatusStripTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/StatusStripTests.cs @@ -1253,7 +1253,7 @@ private class SubToolStripItem : ToolStripItem private class NonReadOnlyControlsStatusStrip : StatusStrip { - protected override ControlCollection CreateControlsInstance() => new ControlCollection(this); + protected override ControlCollection CreateControlsInstance() => new(this); } private class SubStatusStrip : StatusStrip diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TestAccessors.KeyboardToolTipStateMachineTestAccessor.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TestAccessors.KeyboardToolTipStateMachineTestAccessor.cs index c315e4be885..ae545b53e82 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TestAccessors.KeyboardToolTipStateMachineTestAccessor.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TestAccessors.KeyboardToolTipStateMachineTestAccessor.cs @@ -15,5 +15,5 @@ public KeyboardToolTipStateMachineTestAccessor(KeyboardToolTipStateMachine insta } internal static KeyboardToolTipStateMachineTestAccessor TestAccessor(this KeyboardToolTipStateMachine instance) - => new KeyboardToolTipStateMachineTestAccessor(instance); + => new(instance); } diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs index ebac5d69499..1cb809ccfb4 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs @@ -586,8 +586,8 @@ public unsafe void TextRenderer_DrawText_DefaultBackground_RendersTransparent(Fu } public static TheoryData> TextRenderer_DrawText_DefaultBackground_RendersTransparent_TestData - => new TheoryData> - { + => new() + { (IDeviceContext context) => () => TextRenderer.DrawText(context, "Acrylic", SystemFonts.DefaultFont, pt: default, Color.Blue), @@ -611,7 +611,7 @@ public void TextRenderer_Span_ModifyString_ThrowsArgumentOutOfRange(Action actio #pragma warning disable CS0618 // Type or member is obsolete public static TheoryData TextRenderer_Span_ModifyString_ThrowsArgumentOutOfRange_TestData() - => new TheoryData + => new() { () => TextRenderer.DrawText( MockDC.Instance, @@ -712,7 +712,7 @@ public unsafe void TextRenderer_DrawText_Padding_Rectangle(TextFormatFlags flags } public static TheoryData TextRenderer_DrawText_Padding_TestData - => new TheoryData + => new() { { TextFormatFlags.GlyphOverhangPadding, new Rectangle(3, 0, 70, 12) }, { TextFormatFlags.LeftAndRightPadding, new Rectangle(5, 0, 70, 12) }, @@ -736,7 +736,7 @@ public void TextRenderer_MeasureText_Padding(TextFormatFlags flags, Size expecte } public static TheoryData TextRenderer_MeasureText_Padding_TestData - => new TheoryData + => new() { { TextFormatFlags.GlyphOverhangPadding, new Size(78, 13) }, { TextFormatFlags.LeftAndRightPadding, new Size(82, 13) }, @@ -823,7 +823,7 @@ public void TextRenderer_MeasureText_ApplyState(TextFormatFlags flags, Size expe } public static TheoryData TextRenderer_MeasureText_ApplyState_TestData - => new TheoryData + => new() { // State application doesn't practically impact size measurements, but we still want to have a regression test // here in case something sneaks in. diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripItemTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripItemTests.cs index c79b62b53d7..e202b34df91 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripItemTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripItemTests.cs @@ -5883,7 +5883,7 @@ public void ToolStripItem_Margin_GetWithDefaultMargin_ReturnsExpected() private class CustomDefaultMarginToolStripItem : ToolStripItem { - protected internal override Padding DefaultMargin => new Padding(1, 2, 3, 4); + protected internal override Padding DefaultMargin => new(1, 2, 3, 4); } [WinFormsTheory] @@ -6704,7 +6704,7 @@ public void ToolStripItem_Padding_GetWithDefaultPadding_ReturnsExpected() private class CustomDefaultPaddingToolStripItem : ToolStripItem { - protected override Padding DefaultPadding => new Padding(2, 3, 4, 5); + protected override Padding DefaultPadding => new(2, 3, 4, 5); } [WinFormsTheory] @@ -7811,7 +7811,7 @@ public void ToolStripItem_Size_GetWithDefaultSize_ReturnsExpected() private class CustomDefaultSizeToolStripItem : ToolStripItem { - protected override Size DefaultSize => new Size(10, 11); + protected override Size DefaultSize => new(10, 11); } public static IEnumerable Size_Set_TestData() diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/WindowsFormsSynchronizationContextTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/WindowsFormsSynchronizationContextTests.cs index e6eacdfe22c..cfb7a612972 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/WindowsFormsSynchronizationContextTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/WindowsFormsSynchronizationContextTests.cs @@ -16,7 +16,7 @@ public void WindowsFormsSynchronizationContext_CreateCopy_Invoke_Success() Assert.NotSame(context, copy); // Send something. - object state = new object(); + object state = new(); int callCount = 0; SendOrPostCallback callback = (actualState) => { diff --git a/src/System.Windows.Forms/tests/UnitTests/TestAccessorTests.cs b/src/System.Windows.Forms/tests/UnitTests/TestAccessorTests.cs index a7393c0216a..982450641e0 100644 --- a/src/System.Windows.Forms/tests/UnitTests/TestAccessorTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/TestAccessorTests.cs @@ -204,7 +204,7 @@ public class PrivateTestClass { private int _integer; private readonly int _readOnlyInteger; - private List _list = new List { "42" }; + private List _list = new() { "42" }; private long Long { get; set; } diff --git a/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs b/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs index 7ba99c72cf6..5df8331449c 100644 --- a/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs +++ b/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs @@ -88,7 +88,7 @@ public void Font_MeasureText(string family, float size, Size proposedSize, uint } public static TheoryData MeasureTextData => - new TheoryData + new() { { "Arial", 9.0f, new Size(-1, -1), (uint)DRAW_TEXT_FORMAT.DT_BOTTOM, new Size(173, 15) }, { "Arial", 12.0f, new Size(-1, -1), (uint)DRAW_TEXT_FORMAT.DT_BOTTOM, new Size(215, 18) }, @@ -152,7 +152,7 @@ public unsafe void Font_AdjustForVerticalAlignment(string family, float size, Re } public static TheoryData AdjustData => - new TheoryData + new() { { "Arial", 9.0f, new Rectangle(1, 1, 1, 1), (uint)DRAW_TEXT_FORMAT.DT_BOTTOM, new Rectangle(1, 1, 1, 1) }, { "Arial", 12.0f, new Rectangle(1, 1, 1, 1), (uint)DRAW_TEXT_FORMAT.DT_BOTTOM, new Rectangle(1, 1, 1, 1) }, From 3c533c433749d6468d8ce35c420c33a1a48f780b Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Fri, 21 Jul 2023 12:28:09 +0000 Subject: [PATCH 002/231] [main] Update dependencies from dotnet/runtime (#9538) [main] Update dependencies from dotnet/runtime --- eng/Version.Details.xml | 168 ++++++++++++++++++++-------------------- eng/Versions.props | 52 ++++++------- global.json | 2 +- 3 files changed, 111 insertions(+), 111 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 8a7f26b422d..2addc301f71 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,174 +7,174 @@ Note: if the Uri is a new place, you will need to add a subscription from that p --> - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 - + https://github.com/dotnet/runtime - 4f933e1f77e211a73a44a3e3a1e5fb079d498ab7 + a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 diff --git a/eng/Versions.props b/eng/Versions.props index 6d45b73bdd1..a6c76262b27 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -13,34 +13,34 @@ - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 5.0.0-preview.7.20320.5 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 6.0.0 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 - 8.0.0-preview.7.23367.16 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23370.7 diff --git a/global.json b/global.json index f9dafb285fc..9ab06a11ab6 100644 --- a/global.json +++ b/global.json @@ -18,7 +18,7 @@ "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23369.2", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23369.2", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", - "Microsoft.NET.Sdk.IL": "8.0.0-preview.7.23367.16" + "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23370.7" }, "native-tools": { "cmake": "latest" From 0d1f22a4703de2c6abcf1050f282072dd2c8f0b7 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:10:20 +0000 Subject: [PATCH 003/231] [main] Update dependencies from dotnet/arcade (#9537) Update dependencies from https://github.com/dotnet/arcade build 20230720.6 Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.CMake.Sdk , Microsoft.DotNet.GenFacades , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.XUnitExtensions From Version 8.0.0-beta.23369.2 -> To Version 8.0.0-beta.23370.6 Co-authored-by: dotnet-maestro[bot] --- eng/Version.Details.xml | 24 ++++++++++++------------ eng/Versions.props | 6 +++--- eng/common/sdl/configure-sdl-tool.ps1 | 4 +++- global.json | 6 +++--- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 2addc301f71..c69ad7acfef 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -179,29 +179,29 @@ Note: if the Uri is a new place, you will need to add a subscription from that p - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 - + https://github.com/dotnet/arcade - 9fba71ca242ef84c4b7696c380cc00efe734adb3 + a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 diff --git a/eng/Versions.props b/eng/Versions.props index a6c76262b27..6637503733f 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -53,9 +53,9 @@ - 8.0.0-beta.23369.2 - 8.0.0-beta.23369.2 - 8.0.0-beta.23369.2 + 8.0.0-beta.23370.6 + 8.0.0-beta.23370.6 + 8.0.0-beta.23370.6 17.4.0-preview-20220707-01 diff --git a/eng/common/sdl/configure-sdl-tool.ps1 b/eng/common/sdl/configure-sdl-tool.ps1 index e4108e39d9a..27f5a4115fc 100644 --- a/eng/common/sdl/configure-sdl-tool.ps1 +++ b/eng/common/sdl/configure-sdl-tool.ps1 @@ -93,7 +93,9 @@ try { } 'binskim' { if ($targetDirectory) { - $tool.Args += "`"Target < $TargetDirectory\**`"" + # Binskim crashes due to specific PDBs. GitHub issue: https://github.com/microsoft/binskim/issues/924. + # We are excluding all `_.pdb` files from the scan. + $tool.Args += "`"Target < $TargetDirectory\**;-:file|$TargetDirectory\**\_.pdb`"" } $tool.Args += $BinskimAdditionalRunConfigParams } diff --git a/global.json b/global.json index 9ab06a11ab6..228e7e49e3c 100644 --- a/global.json +++ b/global.json @@ -14,9 +14,9 @@ "version": "8.0.100-preview.6.23330.14" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23369.2", - "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23369.2", - "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23369.2", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23370.6", + "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23370.6", + "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23370.6", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23370.7" }, From b64f3233509a40e40f860a8af86712dc6fb36ad7 Mon Sep 17 00:00:00 2001 From: gpetrou <4172445+gpetrou@users.noreply.github.com> Date: Fri, 21 Jul 2023 22:54:00 +0300 Subject: [PATCH 004/231] Enable nullability in some AxHost members (#9523) --- .../src/PublicAPI.Shipped.txt | 12 +-- .../Forms/AxHost.AxPropertyDescriptor.cs | 2 +- .../Windows/Forms/AxHost.OleInterfaces.cs | 2 +- .../src/System/Windows/Forms/AxHost.State.cs | 2 +- .../src/System/Windows/Forms/AxHost.cs | 88 +++++++++---------- 5 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt index 3cfbd49a94f..a411cd968e1 100644 --- a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt +++ b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt @@ -318,15 +318,15 @@ ~static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form sourceForm) -> void ~static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form sourceForm, string key) -> void ~static System.Windows.Forms.TreeNode.FromHandle(System.Windows.Forms.TreeView tree, nint handle) -> System.Windows.Forms.TreeNode -~System.Windows.Forms.AxHost.ContainingControl.get -> System.Windows.Forms.ContainerControl -~System.Windows.Forms.AxHost.ContainingControl.set -> void +System.Windows.Forms.AxHost.ContainingControl.get -> System.Windows.Forms.ContainerControl? +System.Windows.Forms.AxHost.ContainingControl.set -> void ~System.Windows.Forms.AxHost.GetOcx() -> object -~System.Windows.Forms.AxHost.OcxState.get -> System.Windows.Forms.AxHost.State -~System.Windows.Forms.AxHost.OcxState.set -> void +System.Windows.Forms.AxHost.OcxState.get -> System.Windows.Forms.AxHost.State? +System.Windows.Forms.AxHost.OcxState.set -> void ~System.Windows.Forms.AxHost.RaiseOnMouseDown(object o1, object o2, object o3, object o4) -> void ~System.Windows.Forms.AxHost.RaiseOnMouseMove(object o1, object o2, object o3, object o4) -> void ~System.Windows.Forms.AxHost.RaiseOnMouseUp(object o1, object o2, object o3, object o4) -> void -~System.Windows.Forms.AxHost.SetAboutBoxDelegate(System.Windows.Forms.AxHost.AboutBoxDelegate d) -> void +System.Windows.Forms.AxHost.SetAboutBoxDelegate(System.Windows.Forms.AxHost.AboutBoxDelegate! d) -> void ~System.Windows.Forms.AxHost.ShowPropertyPages(System.Windows.Forms.Control control) -> void ~System.Windows.Forms.Binding.BindableComponent.get -> System.Windows.Forms.IBindableComponent ~System.Windows.Forms.Binding.Binding(string propertyName, object dataSource, string dataMember) -> void @@ -690,7 +690,7 @@ ~System.Windows.Forms.TreeView.TopNode.set -> void ~System.Windows.Forms.TreeView.TreeViewNodeSorter.get -> System.Collections.IComparer ~System.Windows.Forms.TreeView.TreeViewNodeSorter.set -> void -~virtual System.Windows.Forms.AxHost.CreateInstanceCore(System.Guid clsid) -> object +virtual System.Windows.Forms.AxHost.CreateInstanceCore(System.Guid clsid) -> object? ~virtual System.Windows.Forms.Binding.OnBindingComplete(System.Windows.Forms.BindingCompleteEventArgs e) -> void ~virtual System.Windows.Forms.Binding.OnFormat(System.Windows.Forms.ConvertEventArgs cevent) -> void ~virtual System.Windows.Forms.Binding.OnParse(System.Windows.Forms.ConvertEventArgs cevent) -> void diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyDescriptor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyDescriptor.cs index cb41a6f998b..470493e6290 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyDescriptor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.AxPropertyDescriptor.cs @@ -51,7 +51,7 @@ internal AxPropertyDescriptor(PropertyDescriptor baseDescriptor, AxHost owner) : } // Use the CategoryAttribute provided by the OCX. - CategoryAttribute cat = owner.GetCategoryForDispid(_dispid.Value); + CategoryAttribute? cat = owner.GetCategoryForDispid(_dispid.Value); if (cat is not null) { AddAttribute(cat); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.OleInterfaces.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.OleInterfaces.cs index 84860c4d84a..7b7b9b7365d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.OleInterfaces.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.OleInterfaces.cs @@ -130,7 +130,7 @@ protected override unsafe HRESULT Invoke( return HRESULT.E_POINTER; } - object ambient = _host.GetAmbientProperty(dispId); + object? ambient = _host.GetAmbientProperty(dispId); if (ambient is not null) { Marshal.GetNativeVariantForObject(ambient, (nint)result); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.State.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.State.cs index 017a31675a6..3d3587d1462 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.State.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.State.cs @@ -34,7 +34,7 @@ public class State : ISerializable, IDisposable private const string DataSerializationName = "Data"; // Create on save from IPersistStream. - internal State(MemoryStream memoryStream, int storageType, AxHost control, PropertyBagStream propertyBag) + internal State(MemoryStream memoryStream, int storageType, AxHost control, PropertyBagStream? propertyBag) { Type = storageType; _propertyBag = propertyBag; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs index c91d2d1368c..e4fcfe8de50 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/AxHost.cs @@ -437,28 +437,28 @@ public void EndInit() { ParentInternal.CreateControl(true); - ContainerControl f = ContainingControl; - if (f is not null) + ContainerControl? containingControl = ContainingControl; + if (containingControl is not null) { - f.VisibleChanged += _onContainerVisibleChanged; + containingControl.VisibleChanged += _onContainerVisibleChanged; } } } private void OnContainerVisibleChanged(object? sender, EventArgs e) { - ContainerControl f = ContainingControl; - if (f is not null) + ContainerControl? containingControl = ContainingControl; + if (containingControl is not null) { - if (f.Visible && Visible && !_axState[s_fOwnWindow]) + if (containingControl.Visible && Visible && !_axState[s_fOwnWindow]) { MakeVisibleWithShow(); } - else if (!f.Visible && Visible && IsHandleCreated && GetOcState() >= OC_INPLACE) + else if (!containingControl.Visible && Visible && IsHandleCreated && GetOcState() >= OC_INPLACE) { HideAxControl(); } - else if (f.Visible && !GetState(States.Visible) && IsHandleCreated && GetOcState() >= OC_INPLACE) + else if (containingControl.Visible && !GetState(States.Visible) && IsHandleCreated && GetOcState() >= OC_INPLACE) { HideAxControl(); } @@ -951,8 +951,8 @@ public override ISite? Site { TransitionDownTo(OC_LOADED); TransitionUpTo(OC_INPLACE); - ContainerControl f = ContainingControl; - if (f is not null && f.Visible && Visible) + ContainerControl? containingControl = ContainingControl; + if (containingControl is not null && containingControl.Visible && Visible) { MakeVisibleWithShow(); } @@ -1303,7 +1303,7 @@ private bool CheckSubclassing() _axState[s_manualUpdate] = true; return false; } -#nullable disable + /// /// Destroys the handle associated with this control. /// User code should in general not call this function. @@ -1508,12 +1508,12 @@ private void InPlaceActivate() private HRESULT InPlaceDeactivate() { _axState[s_ownDisposing] = true; - ContainerControl f = ContainingControl; - if (f is not null) + ContainerControl? containingControl = ContainingControl; + if (containingControl is not null) { - if (f.ActiveControl == this) + if (containingControl.ActiveControl == this) { - f.ActiveControl = null; + containingControl.ActiveControl = null; } } @@ -1640,8 +1640,8 @@ protected override void SetVisibleCore(bool value) private void MakeVisibleWithShow() { - ContainerControl container = ContainingControl; - Control control = container?.ActiveControl; + ContainerControl? container = ContainingControl; + Control? control = container?.ActiveControl; try { DoVerb((int)OLEIVERB.OLEIVERB_SHOW); @@ -1872,7 +1872,7 @@ protected void SetAboutBoxDelegate(AboutBoxDelegate d) [RefreshProperties(RefreshProperties.All)] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] - public State OcxState + public State? OcxState { get { @@ -1924,7 +1924,7 @@ public State OcxState } } - private State CreateNewOcxState(State oldOcxState) + private State? CreateNewOcxState(State? oldOcxState) { NoComponentChangeEvents++; @@ -1935,7 +1935,7 @@ private State CreateNewOcxState(State oldOcxState) return null; } - PropertyBagStream propBag = null; + PropertyBagStream? propBag = null; if (_iPersistPropBag is not null) { @@ -1944,7 +1944,7 @@ private State CreateNewOcxState(State oldOcxState) _iPersistPropBag.Save(propertyBag, fClearDirty: true, fSaveAllProperties: true); } - MemoryStream ms = null; + MemoryStream? ms = null; switch (_storageType) { case STG_STREAM: @@ -1954,11 +1954,11 @@ private State CreateNewOcxState(State oldOcxState) { if (_storageType == STG_STREAM) { - _iPersistStream.Save(stream, true); + _iPersistStream!.Save(stream, true); } else { - _iPersistStreamInit.Save(stream, true); + _iPersistStreamInit!.Save(stream, true); } } @@ -1967,7 +1967,7 @@ private State CreateNewOcxState(State oldOcxState) Debug.Assert(oldOcxState is not null, "we got to have an old state which holds out scribble storage..."); if (oldOcxState is not null) { - return oldOcxState.RefreshStorage(_iPersistStorage); + return oldOcxState.RefreshStorage(_iPersistStorage!); } return null; @@ -2024,7 +2024,7 @@ private State CreateNewOcxState(State oldOcxState) [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Advanced)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public ContainerControl ContainingControl + public ContainerControl? ContainingControl { get => _containingControl ??= FindContainerControlInternal(); set => _containingControl = value; @@ -2053,14 +2053,14 @@ internal override bool ShouldSerializeText() [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeContainingControl() => ContainingControl != ParentInternal; - private ContainerControl FindContainerControlInternal() + private ContainerControl? FindContainerControlInternal() { - if (Site.TryGetService(out IDesignerHost host) && host.RootComponent is ContainerControl rootControl) + if (Site.TryGetService(out IDesignerHost? host) && host.RootComponent is ContainerControl rootControl) { return rootControl; } - Control control = this; + Control? control = this; while (control is not null) { if (control is ContainerControl containerControl) @@ -2099,13 +2099,13 @@ private bool IsDirty() switch (_storageType) { case STG_STREAM: - hr = _iPersistStream.IsDirty(); + hr = _iPersistStream!.IsDirty(); break; case STG_STREAMINIT: - hr = _iPersistStreamInit.IsDirty(); + hr = _iPersistStreamInit!.IsDirty(); break; case STG_STORAGE: - hr = _iPersistStorage.IsDirty(); + hr = _iPersistStorage!.IsDirty(); break; default: Debug.Fail("unknown storage type"); @@ -2125,13 +2125,13 @@ private bool IsDirty() internal bool IsUserMode() { - ISite site = Site; + ISite? site = Site; return site is null || !site.DesignMode; } - private object GetAmbientProperty(int dispid) + private object? GetAmbientProperty(int dispid) { - Control richParent = ParentInternal; + Control? richParent = ParentInternal; switch (dispid) { @@ -2185,7 +2185,7 @@ private object GetAmbientProperty(int dispid) return PInvoke.GetThreadLocale(); case PInvoke.DISPID_AMBIENT_RIGHTTOLEFT: s_axHTraceSwitch.TraceVerbose("asked for right to left"); - Control control = this; + Control? control = this; while (control is not null) { if (control.RightToLeft == Forms.RightToLeft.No) @@ -2213,7 +2213,7 @@ private object GetAmbientProperty(int dispid) public unsafe void DoVerb(int verb) { - Control parent = ParentInternal; + Control? parent = ParentInternal; RECT posRect = Bounds; using var pClientSite = ComHelpers.TryGetComScope(_oleSite, out HRESULT hr); Debug.Assert(hr.Succeeded); @@ -2275,12 +2275,12 @@ private void SetOcState(int nv) _ocState = nv; } - private string GetLicenseKey() + private string? GetLicenseKey() { return GetLicenseKey(_clsid); } - private unsafe string GetLicenseKey(Guid clsid) + private unsafe string? GetLicenseKey(Guid clsid) { if (_licenseKey is not null || !_axState[s_needLicenseKey]) { @@ -2340,7 +2340,7 @@ private void CreateWithoutLicense(Guid clsid) s_axHTraceSwitch.TraceVerbose($"\t{(_instance is not null)}"); } - private void CreateWithLicense(string license, Guid clsid) + private void CreateWithLicense(string? license, Guid clsid) { if (license is not null) { @@ -2399,7 +2399,7 @@ private void CreateInstance() /// Called to create the ActiveX control. Override this member to perform your own creation logic /// or call base to do the default creation logic. /// - protected virtual object CreateInstanceCore(Guid clsid) + protected virtual object? CreateInstanceCore(Guid clsid) { if (IsUserMode()) { @@ -2413,7 +2413,7 @@ protected virtual object CreateInstanceCore(Guid clsid) return _instance; } - private unsafe CategoryAttribute GetCategoryForDispid(int dispid) + private unsafe CategoryAttribute? GetCategoryForDispid(int dispid) { using var categorizeProperties = ComHelpers.TryGetComScope(_instance, out HRESULT hr); if (hr.Failed) @@ -2434,7 +2434,7 @@ private unsafe CategoryAttribute GetCategoryForDispid(int dispid) return s_categoryNames[index]; } - if (_objectDefinedCategoryNames?.TryGetValue(propcat, out CategoryAttribute category) ?? false + if (_objectDefinedCategoryNames?.TryGetValue(propcat, out CategoryAttribute? category) ?? false && category is not null) { return category; @@ -2464,7 +2464,7 @@ private void SetSelectionStyle(int selectionStyle) Debug.Assert(selectionStyle is >= 0 and <= 2, "Invalid selection style"); _selectionStyle = selectionStyle; - if (Site.TryGetService(out ISelectionService selectionService) && selectionService.GetComponentSelected(this)) + if (Site.TryGetService(out ISelectionService? selectionService) && selectionService.GetComponentSelected(this)) { // The AX Host designer will offer an extender property called "SelectionStyle" if (TypeDescriptor.GetProperties(this)["SelectionStyle"] is { } property && property.PropertyType == typeof(int)) @@ -2496,7 +2496,7 @@ public void InvokeEditMode() { } } - +#nullable disable // // ICustomTypeDescriptor implementation. // From fbb6b5af69fbaa5f9b8f1e9c641af15685008aa9 Mon Sep 17 00:00:00 2001 From: gpetrou <4172445+gpetrou@users.noreply.github.com> Date: Sat, 22 Jul 2023 01:46:10 +0300 Subject: [PATCH 005/231] Enable nullability in DataGridViewComboBoxEditingControl (#9522) * Enable nullability in DataGridViewComboBoxEditingControl * Use expression body --- .../src/PublicAPI.Shipped.txt | 20 +++--- .../DataGridViewComboBoxEditingControl.cs | 64 +++++-------------- 2 files changed, 25 insertions(+), 59 deletions(-) diff --git a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt index a411cd968e1..4dd01c009dd 100644 --- a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt +++ b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt @@ -142,9 +142,9 @@ ~override System.Windows.Forms.DataGridViewComboBoxColumn.CellTemplate.set -> void ~override System.Windows.Forms.DataGridViewComboBoxColumn.Clone() -> object ~override System.Windows.Forms.DataGridViewComboBoxColumn.ToString() -> string -~override System.Windows.Forms.DataGridViewComboBoxEditingControl.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject -~override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnHandleCreated(System.EventArgs e) -> void -~override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnSelectedIndexChanged(System.EventArgs e) -> void +override System.Windows.Forms.DataGridViewComboBoxEditingControl.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject! +override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnHandleCreated(System.EventArgs! e) -> void +override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnSelectedIndexChanged(System.EventArgs! e) -> void ~override System.Windows.Forms.DataGridViewHeaderCell.Clone() -> object ~override System.Windows.Forms.DataGridViewHeaderCell.FormattedValueType.get -> System.Type ~override System.Windows.Forms.DataGridViewHeaderCell.GetInheritedContextMenuStrip(int rowIndex) -> System.Windows.Forms.ContextMenuStrip @@ -935,13 +935,13 @@ virtual System.Windows.Forms.AxHost.CreateInstanceCore(System.Guid clsid) -> obj ~virtual System.Windows.Forms.DataGridViewComboBoxCell.ObjectCollection.this[int index].set -> void ~virtual System.Windows.Forms.DataGridViewComboBoxCell.ValueMember.get -> string ~virtual System.Windows.Forms.DataGridViewComboBoxCell.ValueMember.set -> void -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.ApplyCellStyleToEditingControl(System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle) -> void -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlDataGridView.get -> System.Windows.Forms.DataGridView -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlDataGridView.set -> void -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlFormattedValue.get -> object -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlFormattedValue.set -> void -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingPanelCursor.get -> System.Windows.Forms.Cursor -~virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.GetEditingControlFormattedValue(System.Windows.Forms.DataGridViewDataErrorContexts context) -> object +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.ApplyCellStyleToEditingControl(System.Windows.Forms.DataGridViewCellStyle! dataGridViewCellStyle) -> void +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlDataGridView.get -> System.Windows.Forms.DataGridView? +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlDataGridView.set -> void +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlFormattedValue.get -> object! +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingControlFormattedValue.set -> void +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.EditingPanelCursor.get -> System.Windows.Forms.Cursor! +virtual System.Windows.Forms.DataGridViewComboBoxEditingControl.GetEditingControlFormattedValue(System.Windows.Forms.DataGridViewDataErrorContexts context) -> object! ~virtual System.Windows.Forms.DataGridViewRow.AdjustRowHeaderBorderStyle(System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedRow, bool isLastVisibleRow) -> System.Windows.Forms.DataGridViewAdvancedBorderStyle ~virtual System.Windows.Forms.DataGridViewRow.CreateAccessibilityInstance() -> System.Windows.Forms.AccessibleObject ~virtual System.Windows.Forms.DataGridViewRow.CreateCellsInstance() -> System.Windows.Forms.DataGridViewCellCollection diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.cs index 7612fe4ee40..02e7f656ac3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewComboBoxEditingControl.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable disable - using System.Drawing; using System.Globalization; @@ -11,7 +9,7 @@ namespace System.Windows.Forms; public partial class DataGridViewComboBoxEditingControl : ComboBox, IDataGridViewEditingControl { - private DataGridView _dataGridView; + private DataGridView? _dataGridView; private bool _valueChanged; private int _rowIndex; @@ -20,14 +18,12 @@ public DataGridViewComboBoxEditingControl() : base() TabStop = false; } - protected override AccessibleObject CreateAccessibilityInstance() - { - return new DataGridViewComboBoxEditingControlAccessibleObject(this); - } + protected override AccessibleObject CreateAccessibilityInstance() => + new DataGridViewComboBoxEditingControlAccessibleObject(this); // IDataGridViewEditingControl interface implementation - public virtual DataGridView EditingControlDataGridView + public virtual DataGridView? EditingControlDataGridView { get { @@ -41,10 +37,7 @@ public virtual DataGridView EditingControlDataGridView public virtual object EditingControlFormattedValue { - get - { - return GetEditingControlFormattedValue(DataGridViewDataErrorContexts.Formatting); - } + get => GetEditingControlFormattedValue(DataGridViewDataErrorContexts.Formatting); set { if (value is string valueStr) @@ -60,43 +53,19 @@ public virtual object EditingControlFormattedValue public virtual int EditingControlRowIndex { - get - { - return _rowIndex; - } - set - { - _rowIndex = value; - } + get => _rowIndex; + set => _rowIndex = value; } public virtual bool EditingControlValueChanged { - get - { - return _valueChanged; - } - set - { - _valueChanged = value; - } + get => _valueChanged; + set => _valueChanged = value; } - public virtual Cursor EditingPanelCursor - { - get - { - return Cursors.Default; - } - } + public virtual Cursor EditingPanelCursor => Cursors.Default; - public virtual bool RepositionEditingControlOnValueChange - { - get - { - return false; - } - } + public virtual bool RepositionEditingControlOnValueChange => false; public virtual void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle) { @@ -106,7 +75,7 @@ public virtual void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGri // Our ComboBox does not support transparent back colors Color opaqueBackColor = Color.FromArgb(255, dataGridViewCellStyle.BackColor); BackColor = opaqueBackColor; - _dataGridView.EditingPanel.BackColor = opaqueBackColor; + _dataGridView!.EditingPanel.BackColor = opaqueBackColor; } else { @@ -130,10 +99,7 @@ public virtual bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewW return !dataGridViewWantsInputKey; } - public virtual object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context) - { - return Text; - } + public virtual object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context) => Text; public virtual void PrepareEditingControlForEdit(bool selectAll) { @@ -146,7 +112,7 @@ public virtual void PrepareEditingControlForEdit(bool selectAll) private void NotifyDataGridViewOfValueChange() { _valueChanged = true; - _dataGridView.NotifyCurrentCellDirty(true); + _dataGridView!.NotifyCurrentCellDirty(true); } protected override void OnSelectedIndexChanged(EventArgs e) @@ -171,7 +137,7 @@ protected override void OnHandleCreated(EventArgs e) internal override void ReleaseUiaProvider(HWND handle) { - if (TryGetAccessibilityObject(out AccessibleObject accessibleObject)) + if (TryGetAccessibilityObject(out AccessibleObject? accessibleObject)) { ((DataGridViewComboBoxEditingControlAccessibleObject)accessibleObject).ClearParent(); } From c0e8b9df8fd9dff1f5cfd76ee3e84cbb83d1ff4c Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Sat, 22 Jul 2023 12:27:08 +0000 Subject: [PATCH 006/231] [main] Update dependencies from dotnet/arcade (#9544) [main] Update dependencies from dotnet/arcade --- eng/Version.Details.xml | 24 ++++++++++++------------ eng/Versions.props | 6 +++--- global.json | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index c69ad7acfef..1bf40eeb6ef 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -179,29 +179,29 @@ Note: if the Uri is a new place, you will need to add a subscription from that p - + https://github.com/dotnet/arcade - a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 + 602351e3681015ea789b2aeaa7b2a9156a8baf38 - + https://github.com/dotnet/arcade - a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 + 602351e3681015ea789b2aeaa7b2a9156a8baf38 - + https://github.com/dotnet/arcade - a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 + 602351e3681015ea789b2aeaa7b2a9156a8baf38 - + https://github.com/dotnet/arcade - a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 + 602351e3681015ea789b2aeaa7b2a9156a8baf38 - + https://github.com/dotnet/arcade - a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 + 602351e3681015ea789b2aeaa7b2a9156a8baf38 - + https://github.com/dotnet/arcade - a2d7c72df5b2e36b0f69bbe12ad4d7c52793c745 + 602351e3681015ea789b2aeaa7b2a9156a8baf38 diff --git a/eng/Versions.props b/eng/Versions.props index 6637503733f..232711828e9 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -53,9 +53,9 @@ - 8.0.0-beta.23370.6 - 8.0.0-beta.23370.6 - 8.0.0-beta.23370.6 + 8.0.0-beta.23371.1 + 8.0.0-beta.23371.1 + 8.0.0-beta.23371.1 17.4.0-preview-20220707-01 diff --git a/global.json b/global.json index 228e7e49e3c..43a97d30cef 100644 --- a/global.json +++ b/global.json @@ -14,9 +14,9 @@ "version": "8.0.100-preview.6.23330.14" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23370.6", - "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23370.6", - "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23370.6", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23371.1", + "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23371.1", + "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23371.1", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23370.7" }, From 67cfeb531e831742c06ce71f6f300d7c8a4b7fdb Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Sat, 22 Jul 2023 12:27:50 +0000 Subject: [PATCH 007/231] [main] Update dependencies from dotnet/runtime (#9545) [main] Update dependencies from dotnet/runtime --- eng/Version.Details.xml | 168 ++++++++++++++++++++-------------------- eng/Versions.props | 52 ++++++------- global.json | 2 +- 3 files changed, 111 insertions(+), 111 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 1bf40eeb6ef..f5e468d6c54 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,174 +7,174 @@ Note: if the Uri is a new place, you will need to add a subscription from that p --> - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b - + https://github.com/dotnet/runtime - a4a8e8e712eff30c9223ebdeeeb4c80fb798e972 + 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b diff --git a/eng/Versions.props b/eng/Versions.props index 232711828e9..9787ca7e060 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -13,34 +13,34 @@ - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 5.0.0-preview.7.20320.5 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 6.0.0 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 - 8.0.0-rc.1.23370.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23371.7 diff --git a/global.json b/global.json index 43a97d30cef..30cc4ee0785 100644 --- a/global.json +++ b/global.json @@ -18,7 +18,7 @@ "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23371.1", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23371.1", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", - "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23370.7" + "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23371.7" }, "native-tools": { "cmake": "latest" From e9a35997645b440b605f0d975305e313a6808883 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Sun, 23 Jul 2023 12:27:18 +0000 Subject: [PATCH 008/231] [main] Update dependencies from dotnet/runtime (#9550) [main] Update dependencies from dotnet/runtime --- eng/Version.Details.xml | 168 ++++++++++++++++++++-------------------- eng/Versions.props | 52 ++++++------- global.json | 2 +- 3 files changed, 111 insertions(+), 111 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index f5e468d6c54..8243b278189 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,174 +7,174 @@ Note: if the Uri is a new place, you will need to add a subscription from that p --> - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc - + https://github.com/dotnet/runtime - 3c7027a58ba1b6e3a8861ae628c68293b5cb5f2b + 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc diff --git a/eng/Versions.props b/eng/Versions.props index 9787ca7e060..7b1959c3c84 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -13,34 +13,34 @@ - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 5.0.0-preview.7.20320.5 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 6.0.0 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 - 8.0.0-rc.1.23371.7 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23372.5 diff --git a/global.json b/global.json index 30cc4ee0785..3d7dc611f32 100644 --- a/global.json +++ b/global.json @@ -18,7 +18,7 @@ "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23371.1", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23371.1", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", - "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23371.7" + "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23372.5" }, "native-tools": { "cmake": "latest" From ee81fa9d9f3e42a7c0964bf3bc439be7e4871fb2 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 12:27:13 +0000 Subject: [PATCH 009/231] [main] Update dependencies from dotnet/runtime (#9553) [main] Update dependencies from dotnet/runtime --- eng/Version.Details.xml | 168 ++++++++++++++++++++-------------------- eng/Versions.props | 52 ++++++------- global.json | 2 +- 3 files changed, 111 insertions(+), 111 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 8243b278189..2f97bdecef4 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,174 +7,174 @@ Note: if the Uri is a new place, you will need to add a subscription from that p --> - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c - + https://github.com/dotnet/runtime - 66556c467d0b2419b5c2a261fdfa2703e6b3f6bc + 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c diff --git a/eng/Versions.props b/eng/Versions.props index 7b1959c3c84..44b13333ff0 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -13,34 +13,34 @@ - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 5.0.0-preview.7.20320.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 6.0.0 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 - 8.0.0-rc.1.23372.5 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23374.1 diff --git a/global.json b/global.json index 3d7dc611f32..2d263b7874f 100644 --- a/global.json +++ b/global.json @@ -18,7 +18,7 @@ "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23371.1", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23371.1", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", - "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23372.5" + "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23374.1" }, "native-tools": { "cmake": "latest" From 118df36eb6feea27353e11cc00b00f320d1ccdc2 Mon Sep 17 00:00:00 2001 From: gpetrou <4172445+gpetrou@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:53:56 +0300 Subject: [PATCH 010/231] Enable nullability in some ToolStripManager members (#9418) * Enable nullability in some ToolStripManager members * Simplify if statement * Remove check for null sysFont --- .../src/PublicAPI.Shipped.txt | 16 +-- .../System/Windows/Forms/ToolStripManager.cs | 116 +++++++++--------- .../System/Windows/Forms/ToolStripPanel.cs | 2 +- .../Windows/Forms/ToolStripSettingsManager.cs | 46 +++---- 4 files changed, 88 insertions(+), 92 deletions(-) diff --git a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt index 4dd01c009dd..461a2dbb918 100644 --- a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt +++ b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt @@ -305,18 +305,18 @@ override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnSelectedIndex ~static System.Windows.Forms.HtmlElement.operator ==(System.Windows.Forms.HtmlElement left, System.Windows.Forms.HtmlElement right) -> bool ~static System.Windows.Forms.HtmlWindow.operator !=(System.Windows.Forms.HtmlWindow left, System.Windows.Forms.HtmlWindow right) -> bool ~static System.Windows.Forms.HtmlWindow.operator ==(System.Windows.Forms.HtmlWindow left, System.Windows.Forms.HtmlWindow right) -> bool -~static System.Windows.Forms.ToolStripManager.FindToolStrip(string toolStripName) -> System.Windows.Forms.ToolStrip -~static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form targetForm) -> void -~static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form targetForm, string key) -> void +static System.Windows.Forms.ToolStripManager.FindToolStrip(string! toolStripName) -> System.Windows.Forms.ToolStrip? +static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form! targetForm) -> void +static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form! targetForm, string! key) -> void ~static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip sourceToolStrip, string targetName) -> bool ~static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip sourceToolStrip, System.Windows.Forms.ToolStrip targetToolStrip) -> bool -~static System.Windows.Forms.ToolStripManager.Renderer.get -> System.Windows.Forms.ToolStripRenderer -~static System.Windows.Forms.ToolStripManager.Renderer.set -> void +static System.Windows.Forms.ToolStripManager.Renderer.get -> System.Windows.Forms.ToolStripRenderer! +static System.Windows.Forms.ToolStripManager.Renderer.set -> void ~static System.Windows.Forms.ToolStripManager.RevertMerge(string targetName) -> bool ~static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip targetToolStrip) -> bool ~static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip targetToolStrip, System.Windows.Forms.ToolStrip sourceToolStrip) -> bool -~static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form sourceForm) -> void -~static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form sourceForm, string key) -> void +static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form! sourceForm) -> void +static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form! sourceForm, string! key) -> void ~static System.Windows.Forms.TreeNode.FromHandle(System.Windows.Forms.TreeView tree, nint handle) -> System.Windows.Forms.TreeNode System.Windows.Forms.AxHost.ContainingControl.get -> System.Windows.Forms.ContainerControl? System.Windows.Forms.AxHost.ContainingControl.set -> void @@ -3528,7 +3528,7 @@ static System.Windows.Forms.TextRenderer.MeasureText(System.ReadOnlySpan t static System.Windows.Forms.ToolStrip.SetItemParent(System.Windows.Forms.ToolStripItem! item, System.Windows.Forms.ToolStrip! parent) -> void static System.Windows.Forms.ToolStripManager.IsShortcutDefined(System.Windows.Forms.Keys shortcut) -> bool static System.Windows.Forms.ToolStripManager.IsValidShortcut(System.Windows.Forms.Keys shortcut) -> bool -static System.Windows.Forms.ToolStripManager.RendererChanged -> System.EventHandler +static System.Windows.Forms.ToolStripManager.RendererChanged -> System.EventHandler? static System.Windows.Forms.ToolStripManager.RenderMode.get -> System.Windows.Forms.ToolStripManagerRenderMode static System.Windows.Forms.ToolStripManager.RenderMode.set -> void static System.Windows.Forms.ToolStripManager.VisualStylesEnabled.get -> bool diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs index e28d3eff9c0..d6d677bda69 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable disable - using System.Collections.Concurrent; using System.Drawing; using Microsoft.Win32; @@ -15,22 +13,22 @@ public static partial class ToolStripManager // WARNING: ThreadStatic initialization happens only on the first thread at class CTOR time. // use InitializeThread mechanism to initialize ThreadStatic members [ThreadStatic] - private static WeakRefCollection t_toolStripWeakArrayList; + private static WeakRefCollection? t_toolStripWeakArrayList; [ThreadStatic] - private static WeakRefCollection t_toolStripPanelWeakArrayList; + private static WeakRefCollection? t_toolStripPanelWeakArrayList; [ThreadStatic] private static bool t_initialized; - private static Font s_defaultFont; + private static Font? s_defaultFont; private static ConcurrentDictionary s_defaultFontCache = new(); // WARNING: When subscribing to static event handlers - make sure you unhook from them // otherwise you can leak USER objects on process shutdown. // Consider: use WeakRefCollection [ThreadStatic] - private static Delegate[] t_staticEventHandlers; + private static Delegate?[]? t_staticEventHandlers; private const int StaticEventDefaultRendererChanged = 0; private const int StaticEventCount = 1; @@ -54,33 +52,30 @@ internal static Font DefaultFont { get { - Font sysFont = null; + Font? sysFont = null; // We need to cache the default fonts for the different DPIs. if (DpiHelper.IsPerMonitorV2Awareness) { int dpi = CurrentDpi; - Font retFont = null; - if (s_defaultFontCache.TryGetValue(dpi, out retFont) == false || retFont is null) + if (!s_defaultFontCache.TryGetValue(dpi, out Font? retFont)) { // Default to menu font sysFont = SystemInformation.GetMenuFontForDpi(dpi); - if (sysFont is not null) - { - // Ensure font is in pixels so it displays properly in the property grid at design time. - if (sysFont.Unit != GraphicsUnit.Point) - { - retFont = ControlPaint.FontInPoints(sysFont); - sysFont.Dispose(); - } - else - { - retFont = sysFont; - } - s_defaultFontCache[dpi] = retFont; + // Ensure font is in pixels so it displays properly in the property grid at design time. + if (sysFont.Unit != GraphicsUnit.Point) + { + retFont = ControlPaint.FontInPoints(sysFont); + sysFont.Dispose(); + } + else + { + retFont = sysFont; } + + s_defaultFontCache[dpi] = retFont; } return retFont; @@ -88,7 +83,7 @@ internal static Font DefaultFont else { // Threadsafe local reference - Font retFont = s_defaultFont; + Font? retFont = s_defaultFont; if (retFont is null) { @@ -101,23 +96,21 @@ internal static Font DefaultFont { // Default to menu font sysFont = SystemFonts.MenuFont; + // ...or to control font if menu font unavailable sysFont ??= Control.DefaultFont; - if (sysFont is not null) + // Ensure font is in pixels so it displays properly in the property grid at design time. + if (sysFont.Unit != GraphicsUnit.Point) { - // Ensure font is in pixels so it displays properly in the property grid at design time. - if (sysFont.Unit != GraphicsUnit.Point) - { - s_defaultFont = ControlPaint.FontInPoints(sysFont); - retFont = s_defaultFont; - sysFont.Dispose(); - } - else - { - s_defaultFont = sysFont; - retFont = s_defaultFont; - } + s_defaultFont = ControlPaint.FontInPoints(sysFont); + retFont = s_defaultFont; + sysFont.Dispose(); + } + else + { + s_defaultFont = sysFont; + retFont = s_defaultFont; } return retFont; @@ -136,7 +129,7 @@ internal static WeakRefCollection ToolStrips => t_toolStripWeakArrayList ??= new WeakRefCollection(); /// Static events only!!! - private static void AddEventHandler(int key, Delegate value) + private static void AddEventHandler(int key, Delegate? value) { lock (s_internalSyncObject) { @@ -148,14 +141,14 @@ private static void AddEventHandler(int key, Delegate value) /// /// Find a toolstrip in the weak ref ArrayList, return null if nothing was found /// - public static ToolStrip FindToolStrip(string toolStripName) + public static ToolStrip? FindToolStrip(string toolStripName) { - ToolStrip result = null; + ToolStrip? result = null; for (int i = 0; i < ToolStrips.Count; i++) { - if (ToolStrips[i] is not null && string.Equals(((ToolStrip)ToolStrips[i]).Name, toolStripName, StringComparison.Ordinal)) + if (ToolStrips[i] is ToolStrip toolStrip && string.Equals(toolStrip.Name, toolStripName, StringComparison.Ordinal)) { - result = (ToolStrip)ToolStrips[i]; + result = toolStrip; break; } } @@ -166,14 +159,14 @@ public static ToolStrip FindToolStrip(string toolStripName) /// /// Find a toolstrip in the weak ref ArrayList, return null if nothing was found /// - internal static ToolStrip FindToolStrip(Form owningForm, string toolStripName) + internal static ToolStrip? FindToolStrip(Form owningForm, string toolStripName) { - ToolStrip result = null; + ToolStrip? result = null; for (int i = 0; i < ToolStrips.Count; i++) { - if (ToolStrips[i] is not null && string.Equals(((ToolStrip)ToolStrips[i]).Name, toolStripName, StringComparison.Ordinal)) + if (ToolStrips[i] is ToolStrip toolStrip && string.Equals(toolStrip.Name, toolStripName, StringComparison.Ordinal)) { - result = (ToolStrip)ToolStrips[i]; + result = toolStrip; if (result.FindForm() == owningForm) { break; @@ -249,7 +242,7 @@ private static bool ChangeSelection(ToolStrip start, ToolStrip toolStrip) return true; } - private static Delegate GetEventHandler(int key) + private static Delegate? GetEventHandler(int key) { lock (s_internalSyncObject) { @@ -300,7 +293,7 @@ internal static void NotifyMenuModeChange(bool invalidateText, bool activationCh // If we've toggled the ShowUnderlines value, we'll need to invalidate for (int i = 0; i < ToolStrips.Count; i++) { - if (!(ToolStrips[i] is ToolStrip toolStrip)) + if (ToolStrips[i] is not ToolStrip toolStrip) { toolStripPruneNeeded = true; continue; @@ -342,7 +335,7 @@ internal static void PruneToolStripList() } } - private static void RemoveEventHandler(int key, Delegate value) + private static void RemoveEventHandler(int key, Delegate? value) { lock (s_internalSyncObject) { @@ -366,8 +359,8 @@ internal static bool SelectNextToolStrip(ToolStrip start, bool forward) return false; } - ToolStrip wrappedControl = null; - ToolStrip nextControl = null; + ToolStrip? wrappedControl = null; + ToolStrip? nextControl = null; int startTabIndex = start.TabIndex; int index = ToolStrips.IndexOf(start); @@ -473,7 +466,7 @@ internal static bool SelectNextToolStrip(ToolStrip start, bool forward) /// locks in painting code. /// [ThreadStatic] - private static ToolStripRenderer t_defaultRenderer; + private static ToolStripRenderer? t_defaultRenderer; // types cached for perf. internal static Type s_systemRendererType = typeof(ToolStripSystemRenderer); @@ -481,14 +474,14 @@ internal static bool SelectNextToolStrip(ToolStrip start, bool forward) private static bool s_visualStylesEnabledIfPossible = true; [ThreadStatic] - private static Type t_currentRendererType; + private static Type? t_currentRendererType; private static Type CurrentRendererType { get { InitializeThread(); - return t_currentRendererType; + return t_currentRendererType!; } set => t_currentRendererType = value; } @@ -499,6 +492,7 @@ private static Type CurrentRendererType /// The default renderer for the thread. When ToolStrip.RenderMode is set /// to manager - this is the property used. /// + [AllowNull] public static ToolStripRenderer Renderer { get @@ -514,7 +508,7 @@ public static ToolStripRenderer Renderer CurrentRendererType = (value is null) ? s_defaultRendererType : value.GetType(); t_defaultRenderer = value; - ((EventHandler)GetEventHandler(StaticEventDefaultRendererChanged))?.Invoke(null, EventArgs.Empty); + ((EventHandler?)GetEventHandler(StaticEventDefaultRendererChanged))?.Invoke(null, EventArgs.Empty); } } } @@ -524,7 +518,7 @@ public static ToolStripRenderer Renderer /// Warning: When subscribing to static event handlers - make sure you unhook from them /// otherwise you can leak user objects on process shutdown. /// - public static event EventHandler RendererChanged + public static event EventHandler? RendererChanged { add => AddEventHandler(StaticEventDefaultRendererChanged, value); remove => RemoveEventHandler(StaticEventDefaultRendererChanged, value); @@ -589,7 +583,7 @@ public static bool VisualStylesEnabled if (oldVis != VisualStylesEnabled) { - ((EventHandler)GetEventHandler(StaticEventDefaultRendererChanged))?.Invoke(null, EventArgs.Empty); + ((EventHandler?)GetEventHandler(StaticEventDefaultRendererChanged))?.Invoke(null, EventArgs.Empty); } } } @@ -625,11 +619,11 @@ internal static ToolStripRenderer CreateRenderer(ToolStripRenderMode renderMode) internal static WeakRefCollection ToolStripPanels => t_toolStripPanelWeakArrayList ??= new WeakRefCollection(); - internal static ToolStripPanel ToolStripPanelFromPoint(Control draggedControl, Point screenLocation) + internal static ToolStripPanel? ToolStripPanelFromPoint(Control draggedControl, Point screenLocation) { if (t_toolStripPanelWeakArrayList is not null) { - ISupportToolStripPanel draggedItem = draggedControl as ISupportToolStripPanel; + ISupportToolStripPanel draggedItem = (ISupportToolStripPanel)draggedControl; bool rootWindowCheck = draggedItem.IsCurrentlyDragging; for (int i = 0; i < t_toolStripPanelWeakArrayList.Count; i++) @@ -663,7 +657,7 @@ public static void LoadSettings(Form targetForm) { ArgumentNullException.ThrowIfNull(targetForm); - LoadSettings(targetForm, targetForm.GetType().FullName); + LoadSettings(targetForm, targetForm.GetType().FullName!); } /// @@ -686,7 +680,7 @@ public static void SaveSettings(Form sourceForm) { ArgumentNullException.ThrowIfNull(sourceForm); - SaveSettings(sourceForm, sourceForm.GetType().FullName); + SaveSettings(sourceForm, sourceForm.GetType().FullName!); } /// @@ -713,7 +707,7 @@ internal static bool ShowMenuFocusCues return true; } } - +#nullable disable /// /// Determines if the key combination is valid for a shortcut. /// Must have a modifier key + a regular key. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs index 5137417d964..2728c3a3e04 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripPanel.cs @@ -1049,7 +1049,7 @@ private void MoveInsideContainer(ToolStrip toolStripToDrag, Point clientLocation private void MoveOutsideContainer(ToolStrip toolStripToDrag, Point screenLocation) { // look for another rafting container. - ToolStripPanel panel = ToolStripManager.ToolStripPanelFromPoint(toolStripToDrag, screenLocation); + ToolStripPanel? panel = ToolStripManager.ToolStripPanelFromPoint(toolStripToDrag, screenLocation); if (panel is not null) { using (new LayoutTransaction(panel, panel, null)) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.cs index 0176ab8802c..1fb0f6c5471 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripSettingsManager.cs @@ -114,7 +114,7 @@ private void ApplySettings(List toolStripSettingsToApply) if (!string.IsNullOrEmpty(toolStripSettings.Name)) { // apply the toolstrip settings. - ToolStrip toolStrip = ToolStripManager.FindToolStrip(form, toolStripSettings.Name); + ToolStrip? toolStrip = ToolStripManager.FindToolStrip(form, toolStripSettings.Name); ApplyToolStripSettings(toolStrip, toolStripSettings, itemLocationHash); } } @@ -159,9 +159,9 @@ private void ApplySettings(List toolStripSettingsToApply) if (!string.IsNullOrEmpty(settings.Name)) { // apply the toolstrip settings. - ToolStrip toolStrip = ToolStripManager.FindToolStrip(form, settings.Name); + ToolStrip? toolStrip = ToolStripManager.FindToolStrip(form, settings.Name); ApplyToolStripSettings(toolStrip, settings, itemLocationHash); - toolStripPanel.Join(toolStrip, settings.Location); + toolStripPanel.Join(toolStrip!, settings.Location); } } } @@ -172,31 +172,33 @@ private void ApplySettings(List toolStripSettingsToApply) ResumeAllLayout(form, true); } - private static void ApplyToolStripSettings(ToolStrip toolStrip, SettingsStub settings, Dictionary itemLocationHash) + private static void ApplyToolStripSettings(ToolStrip? toolStrip, SettingsStub settings, Dictionary itemLocationHash) { - if (toolStrip is not null) + if (toolStrip is null) { - toolStrip.Visible = settings.Visible; - toolStrip.Size = settings.Size; + return; + } - // Apply the item order changes. - string? itemNames = settings.ItemOrder; - if (!string.IsNullOrEmpty(itemNames)) - { - string[] keys = itemNames.Split(','); - Regex r = ContiguousNonWhitespace(); + toolStrip.Visible = settings.Visible; + toolStrip.Size = settings.Size; - // Shuffle items according to string. - for (int i = 0; ((i < toolStrip.Items.Count) && (i < keys.Length)); i++) + // Apply the item order changes. + string? itemNames = settings.ItemOrder; + if (!string.IsNullOrEmpty(itemNames)) + { + string[] keys = itemNames.Split(','); + Regex r = ContiguousNonWhitespace(); + + // Shuffle items according to string. + for (int i = 0; ((i < toolStrip.Items.Count) && (i < keys.Length)); i++) + { + Match match = r.Match(keys[i]); + if (match.Success) { - Match match = r.Match(keys[i]); - if (match.Success) + string key = match.Value; + if (!string.IsNullOrEmpty(key) && itemLocationHash.TryGetValue(key, out ToolStrip? value)) { - string key = match.Value; - if (!string.IsNullOrEmpty(key) && itemLocationHash.TryGetValue(key, out ToolStrip? value)) - { - toolStrip.Items.Insert(i, value.Items[key]!); - } + toolStrip.Items.Insert(i, value.Items[key]!); } } } From 11473c5e29849269f6690b1127af2f0b25904be6 Mon Sep 17 00:00:00 2001 From: gpetrou <4172445+gpetrou@users.noreply.github.com> Date: Mon, 24 Jul 2023 21:56:15 +0300 Subject: [PATCH 011/231] Enable nullability in remaining ToolStripManager members (#9555) --- .../src/PublicAPI.Shipped.txt | 10 +-- .../src/System/Windows/Forms/Form.cs | 8 +- .../System/Windows/Forms/ToolStripManager.cs | 76 +++++++++---------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt index 461a2dbb918..4ed7e980d2c 100644 --- a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt +++ b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt @@ -308,13 +308,13 @@ override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnSelectedIndex static System.Windows.Forms.ToolStripManager.FindToolStrip(string! toolStripName) -> System.Windows.Forms.ToolStrip? static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form! targetForm) -> void static System.Windows.Forms.ToolStripManager.LoadSettings(System.Windows.Forms.Form! targetForm, string! key) -> void -~static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip sourceToolStrip, string targetName) -> bool -~static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip sourceToolStrip, System.Windows.Forms.ToolStrip targetToolStrip) -> bool +static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip! sourceToolStrip, string! targetName) -> bool +static System.Windows.Forms.ToolStripManager.Merge(System.Windows.Forms.ToolStrip! sourceToolStrip, System.Windows.Forms.ToolStrip! targetToolStrip) -> bool static System.Windows.Forms.ToolStripManager.Renderer.get -> System.Windows.Forms.ToolStripRenderer! static System.Windows.Forms.ToolStripManager.Renderer.set -> void -~static System.Windows.Forms.ToolStripManager.RevertMerge(string targetName) -> bool -~static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip targetToolStrip) -> bool -~static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip targetToolStrip, System.Windows.Forms.ToolStrip sourceToolStrip) -> bool +static System.Windows.Forms.ToolStripManager.RevertMerge(string! targetName) -> bool +static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip! targetToolStrip) -> bool +static System.Windows.Forms.ToolStripManager.RevertMerge(System.Windows.Forms.ToolStrip! targetToolStrip, System.Windows.Forms.ToolStrip! sourceToolStrip) -> bool static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form! sourceForm) -> void static System.Windows.Forms.ToolStripManager.SaveSettings(System.Windows.Forms.Form! sourceForm, string! key) -> void ~static System.Windows.Forms.TreeNode.FromHandle(System.Windows.Forms.TreeView tree, nint handle) -> System.Windows.Forms.TreeNode diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs index 589699eb42f..1eecf9d8e24 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Form.cs @@ -5814,7 +5814,7 @@ private void UpdateMdiControlStrip(bool maximized) } #endif - ToolStripManager.RevertMergeInternal(mdiControlStrip.MergedMenu, mdiControlStrip, /*revertMDIStuff*/true); + ToolStripManager.RevertMergeInternal(mdiControlStrip.MergedMenu, mdiControlStrip, revertMDIControls: true); #if DEBUG // double check that RevertMerge doesnt accidentally revert more than it should. @@ -5841,7 +5841,7 @@ private void UpdateMdiControlStrip(bool maximized) HMENU hMenu = PInvoke.GetMenu(this); if (hMenu == HMENU.Null) { - MenuStrip sourceMenuStrip = ToolStripManager.GetMainMenuStrip(this); + MenuStrip? sourceMenuStrip = ToolStripManager.GetMainMenuStrip(this); if (sourceMenuStrip is not null) { MdiControlStrip = new MdiControlStrip(ActiveMdiChildInternal); @@ -5867,10 +5867,10 @@ internal void UpdateMdiWindowListStrip() { if (MdiWindowListStrip is not null && MdiWindowListStrip.MergedMenu is not null) { - ToolStripManager.RevertMergeInternal(MdiWindowListStrip.MergedMenu, MdiWindowListStrip, /*revertMdiStuff*/true); + ToolStripManager.RevertMergeInternal(MdiWindowListStrip.MergedMenu, MdiWindowListStrip, revertMDIControls: true); } - MenuStrip sourceMenuStrip = ToolStripManager.GetMainMenuStrip(this); + MenuStrip? sourceMenuStrip = ToolStripManager.GetMainMenuStrip(this); if (sourceMenuStrip is not null && sourceMenuStrip.MdiWindowListItem is not null) { MdiWindowListStrip ??= new MdiWindowListStrip(); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs index d6d677bda69..ef6f15bfa92 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolStripManager.cs @@ -370,7 +370,7 @@ internal static bool SelectNextToolStrip(ToolStrip start, bool forward) index = (forward) ? (index + 1) % totalCount : (index + totalCount - 1) % totalCount; - if (!(ToolStrips[index] is ToolStrip toolStrip) || + if (ToolStrips[index] is not ToolStrip toolStrip || toolStrip == start) { continue; @@ -707,7 +707,7 @@ internal static bool ShowMenuFocusCues return true; } } -#nullable disable + /// /// Determines if the key combination is valid for a shortcut. /// Must have a modifier key + a regular key. @@ -814,8 +814,8 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) return false; } - Control activeControl = Control.FromChildHandle(m.HWnd); - Control activeControlInChain = activeControl; + Control? activeControl = Control.FromChildHandle(m.HWnd); + Control? activeControlInChain = activeControl; if (activeControlInChain is not null && IsValidShortcut(shortcut)) { @@ -827,7 +827,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) // Check the context menu strip first. if (activeControlInChain.ContextMenuStrip is not null) { - if (activeControlInChain.ContextMenuStrip.Shortcuts.TryGetValue(shortcut, out ToolStripMenuItem item)) + if (activeControlInChain.ContextMenuStrip.Shortcuts.TryGetValue(shortcut, out ToolStripMenuItem? item)) { if (item.ProcessCmdKey(ref m, shortcut)) { @@ -858,7 +858,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) bool isAssociatedContextMenu = false; bool isDoublyAssignedContextMenuStrip = false; - if (!(ToolStrips[i] is ToolStrip toolStrip)) + if (ToolStrips[i] is not ToolStrip toolStrip) { // Consider prune tree. needsPrune = true; @@ -875,17 +875,17 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) // We don't want to process someone else's context menu (e.g. button1 and button2 have context menus) // button2's context menu should not be processed if button1 is the one we're processing. - ToolStripDropDown dropDown = toolStrip as ToolStripDropDown; + ToolStripDropDown dropDown = (ToolStripDropDown)toolStrip; // If a context menu is re-used between the main menu and the // and some other control's context menu, we should go ahead and evaluate it. - if (dropDown.GetFirstDropDown() is ContextMenuStrip toplevelContextMenu) + if (dropDown.GetFirstDropDown() is ContextMenuStrip topLevelContextMenu) { - isDoublyAssignedContextMenuStrip = toplevelContextMenu.IsAssignedToDropDownItem; + isDoublyAssignedContextMenuStrip = topLevelContextMenu.IsAssignedToDropDownItem; if (!isDoublyAssignedContextMenuStrip) { - if (toplevelContextMenu != activeControl.ContextMenuStrip) + if (topLevelContextMenu != activeControl!.ContextMenuStrip) { // The toplevel context menu is NOT the same as the active control's context menu. continue; @@ -907,7 +907,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) // Make sure that were processing shortcuts for the correct window. // since the shortcut lookup is faster than this check we've postponed this to the last // possible moment. - ToolStrip topMostToolStrip = toolStrip.GetToplevelOwnerToolStrip(); + ToolStrip? topMostToolStrip = toolStrip.GetToplevelOwnerToolStrip(); if (topMostToolStrip is not null && activeControl is not null) { HWND rootWindowOfToolStrip = PInvoke.GetAncestor(topMostToolStrip, GET_ANCESTOR_FLAGS.GA_ROOT); @@ -919,7 +919,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) // Double check this is not an MDIContainer type situation... if (Control.FromHandle(rootWindowOfControl) is Form mainForm && mainForm.IsMdiContainer) { - Form toolStripForm = topMostToolStrip.FindForm(); + Form? toolStripForm = topMostToolStrip.FindForm(); if (toolStripForm != mainForm && toolStripForm is not null) { // We should only process shortcuts of the ActiveMDIChild or the Main Form. @@ -932,7 +932,7 @@ internal static bool ProcessShortcut(ref Message m, Keys shortcut) if (isAssociatedContextMenu || rootWindowsMatch || isDoublyAssignedContextMenuStrip) { - if (toolStrip.Shortcuts.TryGetValue(shortcut, out ToolStripMenuItem item)) + if (toolStrip.Shortcuts.TryGetValue(shortcut, out ToolStripMenuItem? item)) { if (item.ProcessCmdKey(ref m, shortcut)) { @@ -976,10 +976,10 @@ internal static bool ProcessMenuKey(ref Message m) Keys keyData = (Keys)(nint)m.LParamInternal; // Search for our menu to work with - Control intendedControl = Control.FromHandle(m.HWnd); - Control toplevelControl = null; + Control? intendedControl = Control.FromHandle(m.HWnd); + Control? toplevelControl = null; - MenuStrip menuStripToActivate = null; + MenuStrip? menuStripToActivate = null; if (intendedControl is not null) { // Search for a menustrip to select. @@ -1053,7 +1053,7 @@ internal static bool ProcessMenuKey(ref Message m) return false; } - internal static MenuStrip GetMainMenuStrip(Control control) + internal static MenuStrip? GetMainMenuStrip(Control control) { if (control is null) { @@ -1062,7 +1062,7 @@ internal static MenuStrip GetMainMenuStrip(Control control) } // Look for a particular main menu strip to be set. - Form mainForm = control.FindForm(); + Form? mainForm = control.FindForm(); if (mainForm is not null && mainForm.MainMenuStrip is not null) { return mainForm.MainMenuStrip; @@ -1072,7 +1072,7 @@ internal static MenuStrip GetMainMenuStrip(Control control) return GetFirstMenuStripRecursive(control.Controls); } - private static MenuStrip GetFirstMenuStripRecursive(Control.ControlCollection controlsToLookIn) + private static MenuStrip? GetFirstMenuStripRecursive(Control.ControlCollection controlsToLookIn) { try { @@ -1085,9 +1085,9 @@ private static MenuStrip GetFirstMenuStripRecursive(Control.ControlCollection co continue; } - if (controlsToLookIn[i] is MenuStrip) + if (controlsToLookIn[i] is MenuStrip menuStrip) { - return controlsToLookIn[i] as MenuStrip; + return menuStrip; } } @@ -1102,7 +1102,7 @@ private static MenuStrip GetFirstMenuStripRecursive(Control.ControlCollection co if ((controlsToLookIn[i].Controls is not null) && controlsToLookIn[i].Controls.Count > 0) { // If it has a valid child collection, append those results to our collection - MenuStrip menuStrip = GetFirstMenuStripRecursive(controlsToLookIn[i].Controls); + MenuStrip? menuStrip = GetFirstMenuStripRecursive(controlsToLookIn[i].Controls); if (menuStrip is not null) { return menuStrip; @@ -1117,11 +1117,11 @@ private static MenuStrip GetFirstMenuStripRecursive(Control.ControlCollection co return null; } - private static ToolStripItem FindMatch(ToolStripItem source, ToolStripItemCollection destinationItems) + private static ToolStripItem? FindMatch(ToolStripItem source, ToolStripItemCollection destinationItems) { // Based on MergeAction: // Append, return the last sibling - ToolStripItem result = null; + ToolStripItem? result = null; if (source is not null) { for (int i = 0; i < destinationItems.Count; i++) @@ -1145,14 +1145,14 @@ private static ToolStripItem FindMatch(ToolStripItem source, ToolStripItemCollec return result; } - internal static List FindMergeableToolStrips(ContainerControl container) + internal static List FindMergeableToolStrips(ContainerControl? container) { List result = new(); if (container is not null) { for (int i = 0; i < ToolStrips.Count; i++) { - ToolStrip candidateTS = (ToolStrip)ToolStrips[i]; + ToolStrip? candidateTS = (ToolStrip?)ToolStrips[i]; if (candidateTS is not null && candidateTS.AllowMerge && container == candidateTS.FindForm()) { result.Add(candidateTS); @@ -1186,7 +1186,7 @@ public static bool Merge(ToolStrip sourceToolStrip, ToolStrip targetToolStrip) canMerge = (canMerge || (sourceToolStrip.AllowMerge && targetToolStrip.AllowMerge && (sourceToolStrip.GetType().IsAssignableFrom(targetToolStrip.GetType()) || targetToolStrip.GetType().IsAssignableFrom(sourceToolStrip.GetType())))); - MergeHistory mergeHistory = null; + MergeHistory? mergeHistory = null; if (canMerge) { Debug.Indent(); @@ -1240,7 +1240,7 @@ private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection case MergeAction.MatchOnly: case MergeAction.Replace: case MergeAction.Remove: - ToolStripItem item = FindMatch(source, destinationItems); + ToolStripItem? item = FindMatch(source, destinationItems); if (item is not null) { switch (source.MergeAction) @@ -1292,7 +1292,7 @@ private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection { maction = new MergeHistoryItem(MergeAction.Remove) { - PreviousIndexCollection = source.Owner.Items + PreviousIndexCollection = source.Owner!.Items }; maction.PreviousIndex = maction.PreviousIndexCollection.IndexOf(source); maction.TargetItem = source; @@ -1312,7 +1312,7 @@ private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection { maction = new MergeHistoryItem(MergeAction.Remove) { - PreviousIndexCollection = source.Owner.Items + PreviousIndexCollection = source.Owner!.Items }; maction.PreviousIndex = maction.PreviousIndexCollection.IndexOf(source); maction.TargetItem = source; @@ -1327,7 +1327,7 @@ private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection case MergeAction.Append: maction = new MergeHistoryItem(MergeAction.Remove) { - PreviousIndexCollection = source.Owner.Items + PreviousIndexCollection = source.Owner!.Items }; maction.PreviousIndex = maction.PreviousIndexCollection.IndexOf(source); maction.TargetItem = source; @@ -1349,7 +1349,7 @@ public static bool Merge(ToolStrip sourceToolStrip, string targetName) ArgumentNullException.ThrowIfNull(sourceToolStrip); ArgumentNullException.ThrowIfNull(targetName); - ToolStrip target = FindToolStrip(targetName); + ToolStrip? target = FindToolStrip(targetName); if (target is null) { return false; @@ -1363,7 +1363,7 @@ public static bool Merge(ToolStrip sourceToolStrip, string targetName) /// /// Doesn't do a null check on source - if it's null we unmerge everything /// - internal static bool RevertMergeInternal(ToolStrip targetToolStrip, ToolStrip sourceToolStrip, bool revertMDIControls) + internal static bool RevertMergeInternal(ToolStrip targetToolStrip, ToolStrip? sourceToolStrip, bool revertMDIControls) { bool result = false; ArgumentNullException.ThrowIfNull(targetToolStrip); @@ -1430,12 +1430,12 @@ internal static bool RevertMergeInternal(ToolStrip targetToolStrip, ToolStrip so switch (historyItem.MergeAction) { case MergeAction.Remove: - historyItem.IndexCollection.Remove(historyItem.TargetItem); + historyItem.IndexCollection!.Remove(historyItem.TargetItem!); // Put it back - historyItem.PreviousIndexCollection.Insert(Math.Min(historyItem.PreviousIndex, historyItem.PreviousIndexCollection.Count), historyItem.TargetItem); + historyItem.PreviousIndexCollection!.Insert(Math.Min(historyItem.PreviousIndex, historyItem.PreviousIndexCollection.Count), historyItem.TargetItem!); break; case MergeAction.Insert: - historyItem.IndexCollection.Insert(Math.Min(historyItem.Index, historyItem.IndexCollection.Count), historyItem.TargetItem); + historyItem.IndexCollection!.Insert(Math.Min(historyItem.Index, historyItem.IndexCollection.Count), historyItem.TargetItem!); // No need to put it back, inserting it in a new collection, moved it at the correct location break; } @@ -1464,7 +1464,7 @@ internal static bool RevertMergeInternal(ToolStrip targetToolStrip, ToolStrip so /// Unmerge two toolstrips /// public static bool RevertMerge(ToolStrip targetToolStrip) - => RevertMergeInternal(targetToolStrip, null, revertMDIControls: false); + => RevertMergeInternal(targetToolStrip, sourceToolStrip: null, revertMDIControls: false); /// /// Unmerge two toolstrips @@ -1481,7 +1481,7 @@ public static bool RevertMerge(ToolStrip targetToolStrip, ToolStrip sourceToolSt /// public static bool RevertMerge(string targetName) { - ToolStrip target = FindToolStrip(targetName); + ToolStrip? target = FindToolStrip(targetName); if (target is null) { return false; From d60d2aad3d4529eb7faeea00f73ab29d61f71cf8 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Mon, 24 Jul 2023 13:43:38 -0700 Subject: [PATCH 012/231] Fix loc for the keyboard buttons. (#9556) * Fix loc for the keyboard buttons. fixes #8440 * Add insert to the list * Update xlf --- .../src/Resources/SR.resx | 12 +++++- .../src/Resources/xlf/SR.cs.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.de.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.es.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.fr.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.it.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.ja.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.ko.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.pl.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.pt-BR.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.ru.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.tr.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.zh-Hans.xlf | 42 +++++++++---------- .../src/Resources/xlf/SR.zh-Hant.xlf | 42 +++++++++---------- 14 files changed, 284 insertions(+), 274 deletions(-) diff --git a/src/System.Windows.Forms/src/Resources/SR.resx b/src/System.Windows.Forms/src/Resources/SR.resx index 6bff516ddb1..f476791b3d8 100644 --- a/src/System.Windows.Forms/src/Resources/SR.resx +++ b/src/System.Windows.Forms/src/Resources/SR.resx @@ -6131,42 +6131,52 @@ Stack trace where the illegal operation occurred was: Alt + {Locked="Alt"} Back Ctrl + {Locked=!de-DE; "Ctrl"} (default) Del + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins + Insert + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) PgDn + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Indicates whether the control will resize itself automatically based on a computation of the default scroll bar dimensions. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf index 0cf816e6d54..b79bf4186f3 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf @@ -11366,8 +11366,8 @@ Trasování zásobníku, kde došlo k neplatné operaci: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Trasování zásobníku, kde došlo k neplatné operaci: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Trasování zásobníku, kde došlo k neplatné operaci: Del - Odstranit - + Odstranit + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - End - + End + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - Enter - + Enter + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - Domů - + Domů + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Vložit - + Insert + Vložit + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Trasování zásobníku, kde došlo k neplatné operaci: PgDn - Page Down - + Page Down + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - Page Up - + Page Up + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Shift - + Shift + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf index 647b9f39570..a6d1c56ae8b 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf @@ -11366,8 +11366,8 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Ctrl - Strg - + Strg + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: Del - Entf - + Entf + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - Beenden - + Beenden + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - EINGABE - + EINGABE + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - Startseite - + Startseite + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Einfg - + Insert + Einfg + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat: PgDn - Bild ab - + Bild ab + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - Bild auf - + Bild auf + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Umschalttaste - + Umschalttaste + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf index a92e21332e7..7b01afaf61e 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf @@ -11366,8 +11366,8 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: Del - Suprimir - + Suprimir + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - Fin - + Fin + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - Entrar - + Entrar + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - Inicio - + Inicio + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Insertar - + Insert + Insertar + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue: PgDn - Avanzar página - + Avanzar página + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - Retroceder página - + Retroceder página + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Mayúsculas - + Mayúsculas + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf index c71f56c17e9..88c0978c997 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf @@ -11366,8 +11366,8 @@ Cette opération non conforme s'est produite sur la trace de la pile : Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Cette opération non conforme s'est produite sur la trace de la pile : Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Cette opération non conforme s'est produite sur la trace de la pile : Del - Supprimer - + Supprimer + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - Fin - + Fin + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - Entrée - + Entrée + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - Début - + Début + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Insertion - + Insert + Insertion + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Cette opération non conforme s'est produite sur la trace de la pile : PgDn - Page suivante - + Page suivante + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - Page précédente - + Page précédente + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Majuscule - + Majuscule + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf index 1f41ec9f703..d8d0a0f9b78 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf @@ -11366,8 +11366,8 @@ Traccia dello stack da cui si è verificata l'operazione non valida: Alt - ALT - + ALT + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Traccia dello stack da cui si è verificata l'operazione non valida: Ctrl - CTRL - + CTRL + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Traccia dello stack da cui si è verificata l'operazione non valida: Del - CANC - + CANC + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - FINE - + FINE + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - INVIO - + INVIO + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - Home - + Home + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - INS - + Insert + INS + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Traccia dello stack da cui si è verificata l'operazione non valida: PgDn - PGGIÙ - + PGGIÙ + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - PGSU - + PGSU + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - MAIUSC - + MAIUSC + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf index 34eda13e3b7..4ba2f343fca 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf @@ -11366,8 +11366,8 @@ Stack trace where the illegal operation occurred was: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Stack trace where the illegal operation occurred was: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Stack trace where the illegal operation occurred was: Del - Delete - + Delete + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - 終了 - + 終了 + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - 入力 - + 入力 + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - ホーム - + ホーム + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Insert - + Insert + Insert + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Stack trace where the illegal operation occurred was: PgDn - PageDown - + PageDown + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - PageUp - + PageUp + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Shift - + Shift + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf index bca63f5563b..c214ee49904 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf @@ -11366,8 +11366,8 @@ Stack trace where the illegal operation occurred was: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Stack trace where the illegal operation occurred was: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Stack trace where the illegal operation occurred was: Del - Delete - + Delete + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - End - + End + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - Enter - + Enter + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - - + + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Insert - + Insert + Insert + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Stack trace where the illegal operation occurred was: PgDn - Page Down - + Page Down + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - Page Up - + Page Up + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Shift - + Shift + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf index e9127615869..a7f84646646 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf @@ -11366,8 +11366,8 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: Del - Delete - + Delete + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - End - + End + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - Enter - + Enter + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - Strona główna - + Strona główna + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Insert - + Insert + Insert + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja: PgDn - Page Down - + Page Down + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - Page Up - + Page Up + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Shift - + Shift + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf index 335b575e02a..e2f083a4c33 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf @@ -11366,8 +11366,8 @@ Rastreamento de pilha em que a operação ilegal ocorreu: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Rastreamento de pilha em que a operação ilegal ocorreu: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Rastreamento de pilha em que a operação ilegal ocorreu: Del - Delete - + Delete + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - End - + End + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - Enter - + Enter + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - Início - + Início + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Insert - + Insert + Insert + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Rastreamento de pilha em que a operação ilegal ocorreu: PgDn - Page Down - + Page Down + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - Page Up - + Page Up + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Shift - + Shift + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf index 4193cf33330..05609091c26 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf @@ -11367,8 +11367,8 @@ Stack trace where the illegal operation occurred was: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11377,8 +11377,8 @@ Stack trace where the illegal operation occurred was: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11387,28 +11387,28 @@ Stack trace where the illegal operation occurred was: Del - DELETE - + DELETE + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - Конец - + Конец + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - ВВОД - + ВВОД + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - Главная - + Главная + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - INSERT - + Insert + INSERT + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11417,18 +11417,18 @@ Stack trace where the illegal operation occurred was: PgDn - PAGE DOWN - + PAGE DOWN + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - PAGE UP - + PAGE UP + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - SHIFT - + SHIFT + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf index f8e9882ccab..5e305334cfd 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf @@ -11366,8 +11366,8 @@ Geçersiz işlemin gerçekleştiği yığın izi: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Geçersiz işlemin gerçekleştiği yığın izi: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Geçersiz işlemin gerçekleştiği yığın izi: Del - Delete - + Delete + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - End - + End + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - Enter - + Enter + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - Giriş - + Giriş + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Insert - + Insert + Insert + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Geçersiz işlemin gerçekleştiği yığın izi: PgDn - Page Down - + Page Down + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - Page Up - + Page Up + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Shift - + Shift + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf index 52f283f1339..a5eeff2f25b 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf @@ -11366,8 +11366,8 @@ Stack trace where the illegal operation occurred was: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Stack trace where the illegal operation occurred was: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Stack trace where the illegal operation occurred was: Del - Delete - + Delete + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - End - + End + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - Enter - + Enter + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - 主页 - + 主页 + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Insert - + Insert + Insert + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Stack trace where the illegal operation occurred was: PgDn - Page Down - + Page Down + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - Page Up - + Page Up + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Shift - + Shift + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf index 06c10daeb3b..5e6cc699718 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf @@ -11366,8 +11366,8 @@ Stack trace where the illegal operation occurred was: Alt - Alt - + Alt + {Locked="Alt"} Back @@ -11376,8 +11376,8 @@ Stack trace where the illegal operation occurred was: Ctrl - Ctrl - + Ctrl + {Locked=!de-DE; "Ctrl"} (default) @@ -11386,28 +11386,28 @@ Stack trace where the illegal operation occurred was: Del - Del - + Del + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Del"} End - End - + End + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "End"} Enter - Enter - + Enter + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Enter"} Home - 首頁 - + 首頁 + {Locked=!fr-FR,!de-DE,!es-ES; "Home"} - Ins - Ins - + Insert + Ins + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES,!zh-Hant; "Insert"} (none) @@ -11416,18 +11416,18 @@ Stack trace where the illegal operation occurred was: PgDn - PgDn - + PgDn + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgDn"} PgUp - PgUp - + PgUp + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "PgUp"} Shift - Shift - + Shift + {Locked=!fr-FR,!de-DE,!it-IT,!es-ES; "Shift"} Occurs when the value of the control changes. From e096c03201d3e4d575a09e00a389041de71d3b88 Mon Sep 17 00:00:00 2001 From: "Simon Zhao (Beyondsoft Corporation)" Date: Tue, 25 Jul 2023 15:51:48 +0800 Subject: [PATCH 013/231] Port TabellayoutPanelDesigner, TabControlDesigner to runtime --- .../src/System.Design.Forwards.cs | 2 + .../src/Resources/SR.resx | 109 +- .../src/Resources/xlf/SR.cs.xlf | 175 ++ .../src/Resources/xlf/SR.de.xlf | 175 ++ .../src/Resources/xlf/SR.es.xlf | 175 ++ .../src/Resources/xlf/SR.fr.xlf | 175 ++ .../src/Resources/xlf/SR.it.xlf | 175 ++ .../src/Resources/xlf/SR.ja.xlf | 175 ++ .../src/Resources/xlf/SR.ko.xlf | 175 ++ .../src/Resources/xlf/SR.pl.xlf | 175 ++ .../src/Resources/xlf/SR.pt-BR.xlf | 175 ++ .../src/Resources/xlf/SR.ru.xlf | 175 ++ .../src/Resources/xlf/SR.tr.xlf | 175 ++ .../src/Resources/xlf/SR.zh-Hans.xlf | 175 ++ .../src/Resources/xlf/SR.zh-Hant.xlf | 175 ++ .../Behavior/TableLayoutPanelBehavior.cs | 453 +++ .../Behavior/TableLayoutPanelResizeGlyph.cs | 77 + .../Windows/Forms/Design/FlowPanelDesigner.cs | 65 + .../Forms/Design/TabControlDesigner.cs | 663 +++++ .../Windows/Forms/Design/TabPageDesigner.cs | 68 + .../Forms/Design/TableLayoutPanelDesigner.cs | 2432 +++++++++++++++++ .../Windows/Forms/Internals/ClientUtils.cs | 17 + .../DemoConsole/MainForm.Designer.cs | 15 +- .../DesignSurface/DemoConsole/MainForm.cs | 20 + .../Forms/Design/DesignerAttributeTests.cs | 2 - 25 files changed, 6193 insertions(+), 5 deletions(-) create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelResizeGlyph.cs create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowPanelDesigner.cs create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabControlDesigner.cs create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageDesigner.cs create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelDesigner.cs diff --git a/src/System.Design/src/System.Design.Forwards.cs b/src/System.Design/src/System.Design.Forwards.cs index 736ef9f0a65..2d973f8f33d 100644 --- a/src/System.Design/src/System.Design.Forwards.cs +++ b/src/System.Design/src/System.Design.Forwards.cs @@ -49,6 +49,8 @@ [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.SplitContainerDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.SplitterPanelDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.SplitterDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TabControlDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TableLayoutPanelDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TextBoxBaseDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TextBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ToolStripDesigner))] diff --git a/src/System.Windows.Forms.Design/src/Resources/SR.resx b/src/System.Windows.Forms.Design/src/Resources/SR.resx index 6ef22cc4d66..63ac666fcb5 100644 --- a/src/System.Windows.Forms.Design/src/Resources/SR.resx +++ b/src/System.Windows.Forms.Design/src/Resources/SR.resx @@ -1317,10 +1317,115 @@ Press Ctrl+Enter to accept Text. Argument must only contain objects of type '{0}'. - + Vertical Splitter Orientation. - + Horizontal Splitter Orientation. + + Add Tab + + + Add tab to '{0}' + + + Remove Tab + + + Remove tab '{0}' from '{1}' + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + A&bsolute + + + &Add Column + + + Add Column on {0} + + + &Add + + + Add Ro&w + + + Add Row on {0} + + + A&utoSize + + + Change SizeType on {0} + + + Clearing Anchor property of {0} for {1} + + + Clearing Dock property of {0} for {1} + + + &Column + + + C&opy TableLayoutPanel + + + &Cut TableLayoutPanel + + + &Delete TableLayoutPanel + + + {0} swapped with {1} + + + &Delete + + + 0 + + + &Edit Rows and Columns... + + + &Insert + + + {0} must be greater than zero. + + + SizeMode + + + &Percentage + + + Remove Last Colu&mn + + + Remove Column on {0} + + + Remo&ve Last Row + + + Remove Row on {0} + + + &Row + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + Resizing {0} within {1} + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + \ No newline at end of file diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf index d643def79a9..1912212c3c3 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf @@ -1712,6 +1712,181 @@ Stisknutím kombinace kláves Ctrl+Enter text přijměte. {0} [zbytek řetězce byl zkrácen]“; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Dok: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf index 5e89ca3f540..3a9b7813499 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf @@ -1712,6 +1712,181 @@ Drücken Sie STRG+EINGABETASTE, um Text zu übernehmen. {0} [Rest der Zeichenfolge wurde abgeschnitten]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Dock: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf index 162b99fe9fb..d09a28fd8eb 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf @@ -1712,6 +1712,181 @@ Presione Ctrl+Entrar para aceptar el texto. {0} [resto de la cadena truncado]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Acoplar: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf index 8107c1ce581..8eec38b7377 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf @@ -1712,6 +1712,181 @@ Appuyez sur Ctrl+Entrée pour valider le texte. {0} [le reste de la chaîne a été tronqué]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Dock : diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf index 7a6442c201f..5d34e996e66 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf @@ -1712,6 +1712,181 @@ Per accettare testo premere CTRL+INVIO. {0} [stringa troncata]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Dock: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf index 85b53bd0403..e424c9d5547 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf @@ -1712,6 +1712,181 @@ Press Ctrl+Enter to accept Text. {0} [残りの文字列は切り詰められました]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: ドッキング: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf index 97c63d80de1..7fecba85259 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf @@ -1712,6 +1712,181 @@ Press Ctrl+Enter to accept Text. {0}[나머지 문자열은 잘림]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: 도킹: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf index 489583e8730..12513dcc195 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf @@ -1712,6 +1712,181 @@ Naciśnij klawisze Ctrl+Enter, aby zaakceptować tekst. {0} [obcięto pozostałą część ciągu]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Zadokuj: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf index ac10f0151d3..61e928dd135 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.pt-BR.xlf @@ -1712,6 +1712,181 @@ Pressione Ctrl+Enter para aceitar Texto. {0} [o restante da cadeia de caracteres foi truncado]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Encaixar: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf index f5dfc4a8749..6edbc3c6be5 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf @@ -1712,6 +1712,181 @@ Press Ctrl+Enter to accept Text. {0} [остаток строки усечен]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Закрепить: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf index da1b54851e9..2a3afeb4232 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf @@ -1712,6 +1712,181 @@ Metni kabul etmek için Ctrl+Enter tuşlarına basın. {0} [dizenin kalan bölümü kesildi]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Yerleştir: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf index 9149586cb2d..b0f1f5811f8 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hans.xlf @@ -1712,6 +1712,181 @@ Press Ctrl+Enter to accept Text. {0} [字符串的其余部分已截断]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: 停靠: diff --git a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf index 061133a38e0..2d472e71724 100644 --- a/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms.Design/src/Resources/xlf/SR.zh-Hant.xlf @@ -1712,6 +1712,181 @@ Press Ctrl+Enter to accept Text. {0} [字串的其餘部分已遭截斷]"; + + Add Tab + Add Tab + + + + Add tab to '{0}' + Add tab to '{0}' + + + + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + Cannot add '{0}' to TabControl. Only TabPages can be directly added to TabControls. + + + + Remove Tab + Remove Tab + + + + Remove tab '{0}' from '{1}' + Remove tab '{0}' from '{1}' + + + + A&bsolute + A&bsolute + + + + &Add Column + &Add Column + + + + Add Column on {0} + Add Column on {0} + + + + &Add + &Add + + + + Add Ro&w + Add Ro&w + + + + Add Row on {0} + Add Row on {0} + + + + A&utoSize + A&utoSize + + + + Change SizeType on {0} + Change SizeType on {0} + + + + Clearing Anchor property of {0} for {1} + Clearing Anchor property of {0} for {1} + + + + Clearing Dock property of {0} for {1} + Clearing Dock property of {0} for {1} + + + + &Column + &Column + + + + C&opy TableLayoutPanel + C&opy TableLayoutPanel + + + + &Cut TableLayoutPanel + &Cut TableLayoutPanel + + + + &Delete TableLayoutPanel + &Delete TableLayoutPanel + + + + {0} swapped with {1} + {0} swapped with {1} + + + + &Delete + &Delete + + + + 0 + 0 + + + + &Edit Rows and Columns... + &Edit Rows and Columns... + + + + &Insert + &Insert + + + + {0} must be greater than zero. + {0} must be greater than zero. + + + + SizeMode + SizeMode + + + + &Percentage + &Percentage + + + + Remove Last Colu&mn + Remove Last Colu&mn + + + + Remove Column on {0} + Remove Column on {0} + + + + Remo&ve Last Row + Remo&ve Last Row + + + + Remove Row on {0} + Remove Row on {0} + + + + &Row + &Row + + + + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + Additional Rows or Columns cannot be created. TableLayoutPanel is full and GrowStyle is 'FixedSize'. + + + + Resizing {0} within {1} + Resizing {0} within {1} + + + + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + TableLayoutPanel cannot expand to contain the control, because the panel's GrowStyle property is set to 'FixedSize'. + + Dock: Dock: diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs new file mode 100644 index 00000000000..8ffa34ee866 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs @@ -0,0 +1,453 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using System.Collections; +using System.ComponentModel.Design; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; + +namespace System.Windows.Forms.Design.Behavior; + +internal class TableLayoutPanelBehavior : Behavior +{ + private TableLayoutPanelDesigner designer;//pointer back to our designer. + private Point lastMouseLoc;//used to track mouse movement deltas + private bool pushedBehavior;//tracks if we've pushed ourself onto the stack + private BehaviorService behaviorService;//used for bounds translation + private IServiceProvider serviceProvider;//cached to allow our behavior to get services + private TableLayoutPanelResizeGlyph tableGlyph;//the glyph being resized + private DesignerTransaction resizeTransaction;//used to make size adjustements within transaction + private PropertyDescriptor resizeProp;//cached property descriptor representing either the row or column styles + private PropertyDescriptor changedProp; //cached property descriptor that refers to the RowSTyles or ColumnStyles collection. + private TableLayoutPanel table; + private StyleHelper rightStyle; + private StyleHelper leftStyle; + private ArrayList styles; //List of the styles + private bool currentColumnStyles; // is Styles for Columns or Rows + +#if DEBUG + private static readonly TraceSwitch tlpResizeSwitch = new("TLPRESIZE", "Behavior service drag & drop messages"); +#else + private static readonly TraceSwitch tlpResizeSwitch; +#endif + + internal TableLayoutPanelBehavior(TableLayoutPanel panel, TableLayoutPanelDesigner designer, IServiceProvider serviceProvider) + {//: base(designer) { + this.table = panel; + this.designer = designer; + this.serviceProvider = serviceProvider; + +#pragma warning disable VSSDK006 + behaviorService = serviceProvider.GetService(typeof(BehaviorService)) as BehaviorService; +#pragma warning restore VSSDK006 + + if (behaviorService is null) + { + Debug.Fail("BehaviorService could not be found!"); + return; + } + + pushedBehavior = false; + lastMouseLoc = Point.Empty; + } + + private void FinishResize() + { + //clear state + pushedBehavior = false; + behaviorService.PopBehavior(this); + lastMouseLoc = Point.Empty; + styles = null; + + // fire ComponentChange events so this event is undoable + IComponentChangeService cs = serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + if (cs is not null && changedProp is not null) + { + cs.OnComponentChanged(table, changedProp, null, null); + changedProp = null; + } + + //attempt to refresh the selection + SelectionManager selManager = serviceProvider.GetService(typeof(SelectionManager)) as SelectionManager; + selManager?.Refresh(); + } + + public override void OnLoseCapture(Glyph g, EventArgs e) + { + if (pushedBehavior) + { + FinishResize(); + + // If we still have a transaction, roll it back. + // + if (resizeTransaction is not null) + { + DesignerTransaction t = resizeTransaction; + resizeTransaction = null; + using (t) + { + t.Cancel(); + } + } + } + } + + internal struct StyleHelper + { + public int index; + public PropertyDescriptor styleProp; + public TableLayoutStyle style; + } + + public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc) + { + //we only care about the right mouse button for resizing + if (button == MouseButtons.Left && g is TableLayoutPanelResizeGlyph) + { + tableGlyph = g as TableLayoutPanelResizeGlyph; + + //select the table + ISelectionService selSvc = serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; + selSvc?.SetSelectedComponents(new object[] { designer.Component }, SelectionTypes.Primary); + + bool isColumn = tableGlyph.Type == TableLayoutPanelResizeGlyph.TableLayoutResizeType.Column; + + //cache some state + lastMouseLoc = mouseLoc; + resizeProp = TypeDescriptor.GetProperties(tableGlyph.Style)[isColumn ? "Width" : "Height"]; + Debug.Assert(resizeProp is not null, "Unable to get the resize property for tableGlyph's Style"); + + IComponentChangeService cs = serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; + if (cs is not null) + { + changedProp = TypeDescriptor.GetProperties(table)[isColumn ? "ColumnStyles" : "RowStyles"]; + int[] widths = isColumn ? table.GetColumnWidths() : table.GetRowHeights(); + + if (changedProp is not null) + { + GetActiveStyleCollection(isColumn); + if (styles is not null && CanResizeStyle(widths)) + { + IDesignerHost host = serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + resizeTransaction = host.CreateTransaction(string.Format(SR.TableLayoutPanelRowColResize, (isColumn ? "Column" : "Row"), designer.Control.Site.Name)); + } + + try + { + int moveIndex = styles.IndexOf(tableGlyph.Style); + rightStyle.index = IndexOfNextStealableStyle(true /*forward*/, moveIndex, widths); + rightStyle.style = (TableLayoutStyle)styles[rightStyle.index]; + rightStyle.styleProp = TypeDescriptor.GetProperties(rightStyle.style)[isColumn ? "Width" : "Height"]; + + leftStyle.index = IndexOfNextStealableStyle(false /*backwards*/, moveIndex, widths); + leftStyle.style = (TableLayoutStyle)styles[leftStyle.index]; + leftStyle.styleProp = TypeDescriptor.GetProperties(leftStyle.style)[isColumn ? "Width" : "Height"]; + + Debug.Assert(leftStyle.styleProp is not null && rightStyle.styleProp is not null, "Couldn't find property descriptor for width or height"); + + cs.OnComponentChanging(table, changedProp); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + if ((resizeTransaction is not null) && (!resizeTransaction.Canceled)) + { + resizeTransaction.Cancel(); + } + } + + throw; + } + } + else + { + return false; + } + } + } + + //push this resizebehavior + behaviorService.PushCaptureBehavior(this); + pushedBehavior = true; + } + + return false; + } + + private void GetActiveStyleCollection(bool isColumn) + { + if ((styles is null || isColumn != currentColumnStyles) && table is not null) + { + styles = new ArrayList(changedProp.GetValue(table) as TableLayoutStyleCollection); + currentColumnStyles = isColumn; + } + } + + private bool ColumnResize + { + get + { + bool ret = false; + if (tableGlyph is not null) + { + ret = tableGlyph.Type == TableLayoutPanelResizeGlyph.TableLayoutResizeType.Column; + } + + return ret; + } + } + + private bool CanResizeStyle(int[] widths) + { + bool canStealFromRight = false; + bool canStealFromLeft = false; + int moveIndex = ((IList)styles).IndexOf(tableGlyph.Style); + if (moveIndex > -1 && moveIndex != styles.Count) + { + canStealFromRight = IndexOfNextStealableStyle(true, moveIndex, widths) != -1; + canStealFromLeft = IndexOfNextStealableStyle(false, moveIndex, widths) != -1; + } + else + { + Debug.Fail("Can't find style " + moveIndex); + return false; + } + + return canStealFromRight && canStealFromLeft; + } + + private int IndexOfNextStealableStyle(bool forward, int startIndex, int[] widths) + { + int stealIndex = -1; + + if (styles is not null) + { + if (forward) + { + for (int i = startIndex + 1; ((i < styles.Count) && (i < widths.Length)); i++) + { + if (((TableLayoutStyle)styles[i]).SizeType != SizeType.AutoSize && widths[i] >= DesignerUtils.MINUMUMSTYLESIZEDRAG) + { + stealIndex = i; + break; + } + } + } + else + { + if (startIndex < widths.Length) + { + for (int i = startIndex; i >= 0; i--) + { + if (((TableLayoutStyle)styles[i]).SizeType != SizeType.AutoSize && widths[i] >= DesignerUtils.MINUMUMSTYLESIZEDRAG) + { + stealIndex = i; + break; + } + } + } + } + } + + return stealIndex; + } + + [SuppressMessage("Microsoft.Portability", "CA1902:AvoidTestingForFloatingPointEquality")] + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) + { + if (pushedBehavior) + { + bool isColumn = ColumnResize; + GetActiveStyleCollection(isColumn); + if (styles is not null) + { + int rightIndex = rightStyle.index; + int leftIndex = leftStyle.index; + + int delta = isColumn ? mouseLoc.X - lastMouseLoc.X : mouseLoc.Y - lastMouseLoc.Y; + if (isColumn && table.RightToLeft == RightToLeft.Yes) + { + delta *= -1; + } + + if (delta == 0) + { + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "0 mouse delta"); + return false; + } + + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "BEGIN RESIZE"); + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "mouse delta: " + delta); + + int[] oldWidths = isColumn ? table.GetColumnWidths() : table.GetRowHeights(); + + int[] newWidths = oldWidths.Clone() as int[]; + + newWidths[rightIndex] -= delta; + newWidths[leftIndex] += delta; + + if (newWidths[rightIndex] < DesignerUtils.MINUMUMSTYLESIZEDRAG || + newWidths[leftIndex] < DesignerUtils.MINUMUMSTYLESIZEDRAG) + { + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "Bottomed out."); + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "END RESIZE\n"); + return false; + } + + // now we must renormalize our new widths into the correct sizes + table.SuspendLayout(); + + int totalPercent = 0; + + //simplest case: two absolute columns just affect each other. + if (((TableLayoutStyle)styles[rightIndex]).SizeType == SizeType.Absolute && + ((TableLayoutStyle)styles[leftIndex]).SizeType == SizeType.Absolute) + { + // VSWhidbey 465751 + // The dimensions reported by GetColumnsWidths() are different + // than the style dimensions when the TLP has borders. Instead + // of always setting the new size directly based on the reported + // sizes, we now base them on the style size if necessary. + float newRightSize = newWidths[rightIndex]; + float rightStyleSize = (float)rightStyle.styleProp.GetValue(rightStyle.style); + + if (rightStyleSize != oldWidths[rightIndex]) + { + newRightSize = Math.Max(rightStyleSize - delta, DesignerUtils.MINUMUMSTYLESIZEDRAG); + } + + float newLeftSize = newWidths[leftIndex]; + float leftStyleSize = (float)leftStyle.styleProp.GetValue(leftStyle.style); + + if (leftStyleSize != oldWidths[leftIndex]) + { + newLeftSize = Math.Max(leftStyleSize + delta, DesignerUtils.MINUMUMSTYLESIZEDRAG); + } + + rightStyle.styleProp.SetValue(rightStyle.style, newRightSize); + leftStyle.styleProp.SetValue(leftStyle.style, newLeftSize); + } + else if (((TableLayoutStyle)styles[rightIndex]).SizeType == SizeType.Percent && + ((TableLayoutStyle)styles[leftIndex]).SizeType == SizeType.Percent) + { + for (int i = 0; i < styles.Count; i++) + { + if (((TableLayoutStyle)styles[i]).SizeType == SizeType.Percent) + { + totalPercent += oldWidths[i]; + } + } + + for (int j = 0; j < 2; j++) + { + int i = j == 0 ? rightIndex : leftIndex; + float newSize = (float)newWidths[i] * 100 / (float)totalPercent; + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "NewSize " + newSize); + + PropertyDescriptor prop = TypeDescriptor.GetProperties(styles[i])[isColumn ? "Width" : "Height"]; + if (prop is not null) + { + prop.SetValue(styles[i], newSize); + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "Resizing column (per) " + i.ToString(CultureInfo.InvariantCulture) + " to " + newSize.ToString(CultureInfo.InvariantCulture)); + } + } + } + else + { +#if DEBUG + for (int i = 0; i < oldWidths.Length; i++) + { + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "Col " + i + ": Old: " + oldWidths[i] + " New: " + newWidths[i]); + } +#endif + + //mixed - just update absolute + int absIndex = ((TableLayoutStyle)styles[rightIndex]).SizeType == SizeType.Absolute ? rightIndex : leftIndex; + PropertyDescriptor prop = TypeDescriptor.GetProperties(styles[absIndex])[isColumn ? "Width" : "Height"]; + if (prop is not null) + { + // VSWhidbey 465751 + // The dimensions reported by GetColumnsWidths() are different + // than the style dimensions when the TLP has borders. Instead + // of always setting the new size directly based on the reported + // sizes, we now base them on the style size if necessary. + float newAbsSize = newWidths[absIndex]; + float curAbsStyleSize = (float)prop.GetValue(styles[absIndex]); + + if (curAbsStyleSize != oldWidths[absIndex]) + { + newAbsSize = Math.Max(absIndex == rightIndex ? curAbsStyleSize - delta : curAbsStyleSize + delta, + DesignerUtils.MINUMUMSTYLESIZEDRAG); + } + + prop.SetValue(styles[absIndex], newAbsSize); + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose, "Resizing column (abs) " + absIndex.ToString(CultureInfo.InvariantCulture) + " to " + newWidths[absIndex]); + } + else + { + Debug.Fail("Can't resize - no propertyescriptor for column"); + } + } + + table.ResumeLayout(true); + + // now determine if the values we pushed into the TLP + // actually had any effect. If they didn't, + // we delay updating the last mouse position so that + // next time a mouse move message comes in the delta is larger. + bool updatedSize = true; + int[] updatedWidths = isColumn ? table.GetColumnWidths() : table.GetRowHeights(); + + for (int i = 0; i < updatedWidths.Length; i++) + { + if (updatedWidths[i] == oldWidths[i] && newWidths[i] != oldWidths[i]) + { + updatedSize = false; + } + } + + if (updatedSize) + { + lastMouseLoc = mouseLoc; + } + } + else + { + lastMouseLoc = mouseLoc; + } + } + + Debug.WriteLineIf(tlpResizeSwitch.TraceVerbose && pushedBehavior, "END RESIZE\n"); + return false; + } + + public override bool OnMouseUp(Glyph g, MouseButtons button) + { + if (pushedBehavior) + { + FinishResize(); + //commit transaction + if (resizeTransaction is not null) + { + DesignerTransaction t = resizeTransaction; + resizeTransaction = null; + using (t) + { + t.Commit(); + } + + resizeProp = null; + } + } + + return false; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelResizeGlyph.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelResizeGlyph.cs new file mode 100644 index 00000000000..1225b34e068 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelResizeGlyph.cs @@ -0,0 +1,77 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using System.Drawing; + +namespace System.Windows.Forms.Design.Behavior; + +internal class TableLayoutPanelResizeGlyph : Glyph +{ + private Rectangle bounds; + private Cursor hitTestCursor; + private TableLayoutStyle style; + private TableLayoutResizeType type; + + internal TableLayoutPanelResizeGlyph(Rectangle controlBounds, TableLayoutStyle style, Cursor hitTestCursor, Behavior behavior) : base(behavior) + { + this.bounds = controlBounds; + this.hitTestCursor = hitTestCursor; + this.style = style; + + if (style is ColumnStyle) + { + type = TableLayoutResizeType.Column; + } + else + { + type = TableLayoutResizeType.Row; + } + } + + public override Rectangle Bounds + { + get + { + return bounds; + } + } + + public TableLayoutStyle Style + { + get + { + return style; + } + } + + public TableLayoutResizeType Type + { + get + { + return type; + } + } + + public override Cursor GetHitTest(Point p) + { + if (bounds.Contains(p)) + { + return hitTestCursor; + } + + return null; + } + + public override void Paint(PaintEventArgs pe) + { + } + + public enum TableLayoutResizeType + { + Column, + Row + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowPanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowPanelDesigner.cs new file mode 100644 index 00000000000..9faaf03d98f --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/FlowPanelDesigner.cs @@ -0,0 +1,65 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using System.Collections; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design; + +internal class FlowPanelDesigner : PanelDesigner +{ + public override bool ParticipatesWithSnapLines + { + get + { + return false; + } + } + + public override IList SnapLines + { + get + { + ArrayList snapLines = (ArrayList)base.SnapLines; + + //identify all the paddings to remove + ArrayList paddingsToRemove = new ArrayList(4); + foreach (SnapLine line in snapLines) + { + if (line.Filter is not null && line.Filter.Contains(SnapLine.Padding)) + { + paddingsToRemove.Add(line); + } + } + + //remove all padding + foreach (SnapLine line in paddingsToRemove) + { + snapLines.Remove(line); + } + + return snapLines; + } + } + + internal override void AddChildControl(Control newChild) + { + // Skip location adjustment because FlowPanel is going to position this control. + + // Also, Skip z-order adjustment because SendToFront will put the new control at the + // beginning of the flow instead of the end, plus FlowLayout is already preventing + // overlap. + this.Control.Controls.Add(newChild); + } + + protected override void OnDragDrop(DragEventArgs de) + { + base.OnDragDrop(de); + + SelectionManager sm = GetService(typeof(SelectionManager)) as SelectionManager; + sm?.Refresh(); + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabControlDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabControlDesigner.cs new file mode 100644 index 00000000000..cf382faf9c9 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabControlDesigner.cs @@ -0,0 +1,663 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing.Design; +using System.Drawing; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design; + +internal class TabControlDesigner : ParentControlDesigner +{ + private bool tabControlSelected; + private DesignerVerbCollection verbs; + private DesignerVerb removeVerb; + private bool disableDrawGrid; + private int persistedSelectedIndex; + private bool addingOnInitialize; + private bool forwardOnDrag; + + protected override bool AllowControlLasso + { + get + { + return false; + } + } + + protected override bool DrawGrid + { + get + { + if (disableDrawGrid) + { + return false; + } + + return base.DrawGrid; + } + } + + public override bool ParticipatesWithSnapLines + { + get + { + if (!forwardOnDrag) + { + return false; + } + else + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + if (pageDesigner is not null) + { + return pageDesigner.ParticipatesWithSnapLines; + } + + return true; + } + } + } + + private int SelectedIndex + { + get + { + return persistedSelectedIndex; + } + set + { + // TabBase.SelectedIndex has no validation logic, so neither do we + persistedSelectedIndex = value; + } + } + + public override DesignerVerbCollection Verbs + { + get + { + if (verbs is null) + { + removeVerb = new DesignerVerb(SR.TabControlRemove, new EventHandler(this.OnRemove)); + + verbs = new DesignerVerbCollection(); + verbs.Add(new DesignerVerb(SR.TabControlAdd, new EventHandler(this.OnAdd))); + verbs.Add(removeVerb); + } + + if (Control is not null) + { + removeVerb.Enabled = Control.Controls.Count > 0; + } + + return verbs; + } + } + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + + // Add 2 tab pages + // member is OK to be null... + try + { + addingOnInitialize = true; + this.OnAdd(this, EventArgs.Empty); + this.OnAdd(this, EventArgs.Empty); + } + finally + { + addingOnInitialize = false; + } + + MemberDescriptor member = TypeDescriptor.GetProperties(component: Component)["Controls"]; + RaiseComponentChanging(member); + RaiseComponentChanged(member, null, null); + + TabControl tc = (TabControl)Component; + if (tc is not null) + { //always Select the First Tab on Initialising the component... + tc.SelectedIndex = 0; + } + } + + public override bool CanParent(Control control) + { + // If the tabcontrol already contains the control we are dropping then don't allow the drop. + // I.e. we don't want to allow local drag-drop for tabcontrols. + return (control is TabPage && !this.Control.Contains(control)); + } + + private void CheckVerbStatus() + { + if (removeVerb is not null) + { + removeVerb.Enabled = Control.Controls.Count > 0; + } + } + + protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) + { + TabControl tc = ((TabControl)Control); + //VSWhidbey #409457 + if (tc.SelectedTab is null) + { + throw new ArgumentException(string.Format(SR.TabControlInvalidTabPageType, tool.DisplayName)); + } + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + TabPageDesigner selectedTabPageDesigner = host.GetDesigner(tc.SelectedTab) as TabPageDesigner; + InvokeCreateTool(selectedTabPageDesigner, tool); + } + + // InvokeCreate Tool will do the necessary hookups. + return null; + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); + if (svc is not null) + { + svc.SelectionChanged -= new EventHandler(this.OnSelectionChanged); + } + + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs is not null) + { + cs.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged); + } + + TabControl tabControl = Control as TabControl; + if (tabControl is not null) + { + tabControl.SelectedIndexChanged -= new EventHandler(this.OnTabSelectedIndexChanged); + tabControl.GotFocus -= new EventHandler(this.OnGotFocus); + tabControl.RightToLeftLayoutChanged -= new EventHandler(this.OnRightToLeftLayoutChanged); + tabControl.ControlAdded -= new ControlEventHandler(this.OnControlAdded); + } + } + + base.Dispose(disposing); + } + + protected override bool GetHitTest(Point point) + { + TabControl tc = ((TabControl)Control); + + // tabControlSelected tells us if a tab page or the tab control itself is selected. + // If the tab control is selected, then we need to return true from here - so we can switch back and forth + // between tabs. If we're not currently selected, we want to select the tab control + // so return false. + if (tabControlSelected) + { + Point hitTest = Control.PointToClient(point); + return !tc.DisplayRectangle.Contains(hitTest); + } + + return false; + } + + internal static TabPage GetTabPageOfComponent(TabControl parent, object comp) + { + if (!(comp is Control)) + { + return null; + } + + Control c = (Control)comp; + while (c is not null) + { + TabPage page = c as TabPage; + if (page is not null && page.Parent == parent) + { + return page; + } + + c = c.Parent; + } + + return null; + } + + public override void Initialize(IComponent component) + { + base.Initialize(component); + + AutoResizeHandles = true; + TabControl control = component as TabControl; + Debug.Assert(control is not null, "Component must be a tab control, it is a: " + component.GetType().FullName); + + ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); + if (svc is not null) + { + svc.SelectionChanged += new EventHandler(this.OnSelectionChanged); + } + + IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (cs is not null) + { + cs.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged); + } + + if (control is not null) + { + control.SelectedIndexChanged += new EventHandler(this.OnTabSelectedIndexChanged); + control.GotFocus += new EventHandler(this.OnGotFocus); + control.RightToLeftLayoutChanged += new EventHandler(this.OnRightToLeftLayoutChanged); + control.ControlAdded += new ControlEventHandler(this.OnControlAdded); + } + } + + private void OnAdd(object sender, EventArgs eevent) + { + TabControl tc = (TabControl)Component; + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + DesignerTransaction t = null; + try + { + try + { + t = host.CreateTransaction(string.Format(SR.TabControlAddTab, Component.Site.Name)); + } + catch (CheckoutException ex) + { + if (ex == CheckoutException.Canceled) + { + return; + } + + throw new CheckoutException("Checkout Error", ex); + } + + MemberDescriptor member = TypeDescriptor.GetProperties(tc)["Controls"]; + TabPage page = (TabPage)host.CreateComponent(typeof(TabPage)); + if (!addingOnInitialize) + { + RaiseComponentChanging(member); + } + + // NOTE: We also modify padding of TabPages added through the TabPageCollectionEditor. + // If you need to change the default Padding, change it there as well. + page.Padding = new Padding(3); + + string pageText = null; + + PropertyDescriptor nameProp = TypeDescriptor.GetProperties(page)["Name"]; + if (nameProp is not null && nameProp.PropertyType == typeof(string)) + { + pageText = nameProp.GetValue(page) as string; + } + + if (pageText is not null) + { + PropertyDescriptor textProperty = TypeDescriptor.GetProperties(page)["Text"]; + Debug.Assert(textProperty is not null, "Could not find 'Text' property in TabPage."); + textProperty?.SetValue(page, pageText); + } + + PropertyDescriptor styleProp = TypeDescriptor.GetProperties(page)["UseVisualStyleBackColor"]; + if (styleProp is not null && styleProp.PropertyType == typeof(bool) && !styleProp.IsReadOnly && styleProp.IsBrowsable) + { + styleProp.SetValue(page, true); + } + + tc.Controls.Add(page); + // Make sure that the last tab is selected. + tc.SelectedIndex = tc.TabCount - 1; + if (!addingOnInitialize) + { + RaiseComponentChanged(member, null, null); + } + } + finally + { + t?.Commit(); + } + } + } + + private void OnComponentChanged(object sender, ComponentChangedEventArgs e) + { + CheckVerbStatus(); + } + + private void OnGotFocus(object sender, EventArgs e) + { + IEventHandlerService eventSvc = (IEventHandlerService)GetService(typeof(IEventHandlerService)); + if (eventSvc is not null) + { + Control focusWnd = eventSvc.FocusWindow; + focusWnd?.Focus(); + } + } + + private void OnRemove(object sender, EventArgs eevent) + { + TabControl tc = (TabControl)Component; + + // if the control is null, or there are not tab pages, get out!... + if (tc is null || tc.TabPages.Count == 0) + { + return; + } + + // member is OK to be null... + MemberDescriptor member = TypeDescriptor.GetProperties(Component)["Controls"]; + + TabPage tp = tc.SelectedTab; + + // destroy the page + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + DesignerTransaction t = null; + try + { + try + { + t = host.CreateTransaction(string.Format(SR.TabControlRemoveTab, ((IComponent)tp).Site.Name, Component.Site.Name)); + RaiseComponentChanging(member); + } + catch (CheckoutException ex) + { + if (ex == CheckoutException.Canceled) + { + return; + } + + throw new CheckoutException("Checkout Error", ex); + } + + if(tp is not null) + { + host.DestroyComponent(tp); + } + + RaiseComponentChanged(member, null, null); + } + finally + { + t?.Commit(); + } + } + } + + protected override void OnPaintAdornments(PaintEventArgs pe) + { + try + { + this.disableDrawGrid = true; + // we don't want to do this for the tab control designer because you can't drag anything onto it anyway. + // so we will always return false for draw grid. + base.OnPaintAdornments(pe); + } + finally + { + this.disableDrawGrid = false; + } + } + + private void OnControlAdded(object sender, ControlEventArgs e) + { + if (e.Control is not null && !e.Control.IsHandleCreated) + { + IntPtr hwnd = e.Control.Handle; + } + } + + private void OnRightToLeftLayoutChanged(object sender, EventArgs e) + { + BehaviorService?.SyncSelection(); + } + + private void OnSelectionChanged(object sender, EventArgs e) + { + ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); + + tabControlSelected = false;//this is for HitTest purposes + + if (svc is not null) + { + ICollection selComponents = svc.GetSelectedComponents(); + + TabControl tabControl = (TabControl)Component; + + foreach (object comp in selComponents) + { + if (comp == tabControl) + { + tabControlSelected = true;//this is for HitTest purposes + } + + TabPage page = GetTabPageOfComponent(tabControl, comp); + + if (page is not null && page.Parent == tabControl) + { + tabControlSelected = false; //this is for HitTest purposes + tabControl.SelectedTab = page; + SelectionManager selMgr = (SelectionManager)GetService(typeof(SelectionManager)); + selMgr.Refresh(); + break; + } + } + } + } + + private void OnTabSelectedIndexChanged(object sender, EventArgs e) + { + // if this was called as a result of a prop change, don't set the selection to the control (causes flicker) + // Attempt to select the tab control + ISelectionService svc = (ISelectionService)GetService(typeof(ISelectionService)); + if (svc is not null) + { + ICollection selComponents = svc.GetSelectedComponents(); + + TabControl tabControl = (TabControl)Component; + bool selectedComponentOnTab = false; + + foreach (object comp in selComponents) + { + TabPage page = GetTabPageOfComponent(tabControl, comp); + if (page is not null && page.Parent == tabControl && page == tabControl.SelectedTab) + { + selectedComponentOnTab = true; + break; + } + } + + if (!selectedComponentOnTab) + { + svc.SetSelectedComponents(new object[] { Component }); + } + } + } + + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + // Handle shadowed properties + string[] shadowProps = new string[] + { + "SelectedIndex", + }; + + Attribute[] empty = Array.Empty(); + + for (int i = 0; i < shadowProps.Length; i++) + { + PropertyDescriptor prop = properties[shadowProps[i]] as PropertyDescriptor; + if (prop is not null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(TabControlDesigner), prop, empty); + } + } + } + + private TabPageDesigner GetSelectedTabPageDesigner() + { + TabPageDesigner pageDesigner = null; + TabPage selectedTab = ((TabControl)Component).SelectedTab; + if (selectedTab is not null) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + pageDesigner = host.GetDesigner(selectedTab) as TabPageDesigner; + } + } + + return pageDesigner; + } + + protected override void OnDragEnter(DragEventArgs de) + { + // Check what we are dragging... If we are just dragging tab pages, then we do not want to forward the OnDragXXX + forwardOnDrag = false; + + DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject; + if (data is not null) + { + ArrayList dragControls; + int primaryIndex = -1; + dragControls = new ArrayList(data.GetSortedDragControls(ref primaryIndex)); + if (dragControls is not null) + { + for (int i = 0; i < dragControls.Count; i++) + { + if (!(dragControls[i] is Control) || (dragControls[i] is Control && !(dragControls[i] is TabPage))) + { + forwardOnDrag = true; + break; + } + } + } + } + else + { + // We must be dragging something off the toolbox, so forward the drag to the right tabpage. + forwardOnDrag = true; + } + + if (forwardOnDrag) + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnDragEnterInternal(de); + } + else + { + base.OnDragEnter(de); + } + } + + protected override void OnDragDrop(DragEventArgs de) + { + if (forwardOnDrag) + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnDragDropInternal(de); + } + else + { + base.OnDragDrop(de); + } + + forwardOnDrag = false; + } + + protected override void OnDragLeave(EventArgs e) + { + if (forwardOnDrag) + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnDragLeaveInternal(e); + } + else + { + base.OnDragLeave(e); + } + + forwardOnDrag = false; + } + + protected override void OnDragOver(DragEventArgs de) + { + if (forwardOnDrag) + { + //Need to make sure that we are over a valid area. VSWhidbey# 354139. Now that all dragging/dropping is done via + //the behavior service and adorner window, we have to do our own validation, and cannot rely on the OS to do it for us. + TabControl tc = ((TabControl)Control); + Point dropPoint = Control.PointToClient(new Point(de.X, de.Y)); + if (!tc.DisplayRectangle.Contains(dropPoint)) + { + de.Effect = DragDropEffects.None; + return; + } + + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnDragOverInternal(de); + } + else + { + base.OnDragOver(de); + } + } + + protected override void OnGiveFeedback(GiveFeedbackEventArgs e) + { + if (forwardOnDrag) + { + TabPageDesigner pageDesigner = GetSelectedTabPageDesigner(); + pageDesigner?.OnGiveFeedbackInternal(e); + } + else + { + base.OnGiveFeedback(e); + } + } + + protected override void WndProc(ref Message m) + { + switch (m.MsgInternal) + { + case PInvoke.WM_NCHITTEST: + // The tab control always fires HTTRANSPARENT in empty areas, which causes the message to go to our parent. We want + // the tab control's designer to get these messages, however, so change this. + base.WndProc(ref m); + if (m.ResultInternal == PInvoke.HTTRANSPARENT) + { + m.ResultInternal = (LRESULT)(nint)PInvoke.HTCLIENT; + } + + break; + case PInvoke.WM_CONTEXTMENU: + base.WndProc(ref m); + break; + case PInvoke.WM_HSCROLL: + case PInvoke.WM_VSCROLL: + //We do this so that we can update the areas covered by glyphs correctly. VSWhidbey# 187405. + //We just invalidate the area corresponding to the ClientRectangle in the adornerwindow. + BehaviorService.Invalidate(BehaviorService.ControlRectInAdornerWindow(Control)); + base.WndProc(ref m); + break; + default: + base.WndProc(ref m); + break; + } + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageDesigner.cs new file mode 100644 index 00000000000..fb02089a9eb --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TabPageDesigner.cs @@ -0,0 +1,68 @@ +using System.ComponentModel.Design; +using System.Drawing; +using System.Windows.Forms.Design.Behavior; + +namespace System.Windows.Forms.Design; + +internal class TabPageDesigner : PanelDesigner +{ + public override bool CanBeParentedTo(IDesigner parentDesigner) + { + return (parentDesigner is not null && parentDesigner.Component is TabControl); + } + + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + Control ctl = Control; + + if (ctl is not null && ctl.Parent is TabControl) + { + rules &= ~SelectionRules.AllSizeable; + } + + return rules; + } + } + + internal void OnDragDropInternal(DragEventArgs de) + { + OnDragDrop(de); + } + + internal void OnDragEnterInternal(DragEventArgs de) + { + OnDragEnter(de); + } + + internal void OnDragLeaveInternal(EventArgs e) + { + OnDragLeave(e); + } + + internal void OnDragOverInternal(DragEventArgs e) + { + OnDragOver(e); + } + + internal void OnGiveFeedbackInternal(GiveFeedbackEventArgs e) + { + OnGiveFeedback(e); + } + + protected override ControlBodyGlyph GetControlGlyph(GlyphSelectionType selectionType) + { + // create a new body glyph with empty bounds. This will keep incorrect tab pages from stealing drag/drop messages + // which are now handled by the TabControlDesigner get the right cursor for this component. + OnSetCursor(); + + Rectangle translatedBounds = Rectangle.Empty; + + //create our glyph, and set its cursor appropriately + ControlBodyGlyph g = new ControlBodyGlyph(translatedBounds, Cursor.Current, Control, this); + + return g; + } +} diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelDesigner.cs new file mode 100644 index 00000000000..b04c84c172a --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TableLayoutPanelDesigner.cs @@ -0,0 +1,2432 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using System.Collections; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing.Design; +using System.Drawing; +using System.Windows.Forms.Design.Behavior; +using System.CodeDom; +using System.ComponentModel.Design.Serialization; +using System.Text.RegularExpressions; + +namespace System.Windows.Forms.Design; + +internal class TableLayoutPanelDesigner : FlowPanelDesigner +{ + private TableLayoutPanelBehavior tlpBehavior;//every resize col/row glyph is associated with this instance of behavior + private Point droppedCellPosition = InvalidPoint;//used to insert new children + + // NEVER USE undoing DIRECTLY. ALWAYS USE THE PROPERTY + private bool undoing; + private UndoEngine undoEngine; + + private Control localDragControl;//only valid if we're currently dragging a child control of the table + private ArrayList dragComps; //the components we are dragging + private DesignerVerbCollection verbs;//add col/row and remove col/row tab verbs + private DesignerTableLayoutControlCollection controls; + private DesignerVerb removeRowVerb; + private DesignerVerb removeColVerb; + private DesignerActionListCollection actionLists;//action list for the Smart Tag + + private BaseContextMenuStrip designerContextMenuStrip; + private int curRow = -1; //row cursor was over when context menu was dropped + private int curCol = -1; //col cursor was over when context menu was dropped + + private IComponentChangeService compSvc; + private PropertyDescriptor rowStyleProp; + private PropertyDescriptor colStyleProp; + + // Only used when adding controls via the toolbox + private int rowCountBeforeAdd; // What's the row count before a control is added + private int colCountBeforeAdd; // Ditto for column + + // TLP context menu row/column items. + private ToolStripMenuItem contextMenuRow; + private ToolStripMenuItem contextMenuCol; + + private int ensureSuspendCount; + + private TableLayoutPanelBehavior Behavior + { + get + { + tlpBehavior ??= new TableLayoutPanelBehavior(Table, this, Component.Site); + + return tlpBehavior; + } + } + + private TableLayoutColumnStyleCollection ColumnStyles + { + get + { + return Table.ColumnStyles; + } + } + + private TableLayoutRowStyleCollection RowStyles + { + get + { + return Table.RowStyles; + } + } + + public int RowCount + { + get + { + return Table.RowCount; + } + set + { + if (value <= 0 && !Undoing) + { + throw new ArgumentException(string.Format(SR.TableLayoutPanelDesignerInvalidColumnRowCount, "RowCount")); + } + else + { + Table.RowCount = value; + } + } + } + + public int ColumnCount + { + get + { + return Table.ColumnCount; + } + set + { + if (value <= 0 && !Undoing) + { + throw new ArgumentException(string.Format(SR.TableLayoutPanelDesignerInvalidColumnRowCount, "ColumnCount")); + } + else + { + Table.ColumnCount = value; + } + } + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + private bool IsLocalizable() + { + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + PropertyDescriptor prop = TypeDescriptor.GetProperties(host.RootComponent)["Localizable"]; + if (prop is not null && prop.PropertyType == typeof(bool)) + { + return (bool)prop.GetValue(host.RootComponent); + } + } + + return false; + } + + private bool ShouldSerializeColumnStyles() + { + return !IsLocalizable(); + } + + private bool ShouldSerializeRowStyles() + { + return !IsLocalizable(); + } + + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + private DesignerTableLayoutControlCollection Controls + { + get + { + controls ??= new DesignerTableLayoutControlCollection((TableLayoutPanel)Control); + return controls; + } + } + + private ContextMenuStrip DesignerContextMenuStrip + { + get + { + if (designerContextMenuStrip is null) + { + designerContextMenuStrip = new BaseContextMenuStrip(Component.Site, Table); + + // Remove all the verbs -- except the Edit Rows and Columns + ContextMenuStripGroup group = designerContextMenuStrip.Groups[StandardGroups.Verbs]; + foreach (DesignerVerb verb in Verbs) + { + if (verb.Text.Equals(string.Format(SR.TableLayoutPanelDesignerEditRowAndCol))) + { + continue; + } + + foreach (ToolStripItem item in group.Items) + { + if (item.Text.Equals(verb.Text)) + { + group.Items.Remove(item); + break; + } + } + } + + // Now build the new menus + ToolStripDropDownMenu rowMenu = BuildMenu(true); + ToolStripDropDownMenu colMenu = BuildMenu(false); + + this.contextMenuRow = new ToolStripMenuItem(); + this.contextMenuRow.DropDown = rowMenu; + this.contextMenuRow.Text = SR.TableLayoutPanelDesignerRowMenu; + + this.contextMenuCol = new ToolStripMenuItem(); + this.contextMenuCol.DropDown = colMenu; + this.contextMenuCol.Text = SR.TableLayoutPanelDesignerColMenu; + + group.Items.Insert(0, contextMenuCol); + group.Items.Insert(0, contextMenuRow); + + group = designerContextMenuStrip.Groups[StandardGroups.Edit]; + foreach (ToolStripItem item in group.Items) + { + if (item.Text.Equals(SR.ContextMenuCut)) + { + item.Text = SR.TableLayoutPanelDesignerContextMenuCut; + } + else if (item.Text.Equals(SR.ContextMenuCopy)) + { + item.Text = SR.TableLayoutPanelDesignerContextMenuCopy; + } + else if (item.Text.Equals(SR.ContextMenuDelete)) + { + item.Text = SR.TableLayoutPanelDesignerContextMenuDelete; + } + } + } + + bool onValidCell = IsOverValidCell(false); + + this.contextMenuRow.Enabled = onValidCell; + this.contextMenuCol.Enabled = onValidCell; + + return designerContextMenuStrip; + } + } + + private bool IsLoading + { + get + { + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + + if (host is not null) + { + return host.Loading; + } + + return false; + } + } + + internal TableLayoutPanel Table + { + get + { + return Component as TableLayoutPanel; + } + } + + private bool Undoing + { + get + { + if (undoEngine is null) + { + undoEngine = GetService(typeof(UndoEngine)) as UndoEngine; + if (undoEngine is not null) + { + undoEngine.Undoing += new EventHandler(this.OnUndoing); + if (undoEngine.UndoInProgress) + { + undoing = true; + undoEngine.Undone += new EventHandler(this.OnUndone); + } + } + } + + return undoing; + } + + set + { + undoing = value; + } + } + + public override DesignerVerbCollection Verbs + { + get + { + if (verbs is null) + { + removeColVerb = new DesignerVerb(SR.TableLayoutPanelDesignerRemoveColumn, new EventHandler(this.OnVerbRemove)); + removeRowVerb = new DesignerVerb(SR.TableLayoutPanelDesignerRemoveRow, new EventHandler(this.OnVerbRemove)); + + verbs = new DesignerVerbCollection(); + + verbs.Add(new DesignerVerb(SR.TableLayoutPanelDesignerAddColumn, new EventHandler(this.OnVerbAdd))); + verbs.Add(new DesignerVerb(SR.TableLayoutPanelDesignerAddRow, new EventHandler(this.OnVerbAdd))); + verbs.Add(removeColVerb); + verbs.Add(removeRowVerb); + verbs.Add(new DesignerVerb(SR.TableLayoutPanelDesignerEditRowAndCol, new EventHandler(this.OnVerbEdit))); + + CheckVerbStatus(); + } + + return verbs; + } + } + + private void RefreshSmartTag() + { + DesignerActionUIService actionUIService = (DesignerActionUIService)GetService(typeof(DesignerActionUIService)); + actionUIService?.Refresh(Component); + } + + private void CheckVerbStatus() + { + if (Table is not null) + { + if (removeColVerb is not null) + { + bool colState = Table.ColumnCount > 1; + if (removeColVerb.Enabled != colState) + { + removeColVerb.Enabled = colState; + } + } + + if (removeRowVerb is not null) + { + bool rowState = Table.RowCount > 1; + if (removeRowVerb.Enabled != rowState) + { + removeRowVerb.Enabled = rowState; + } + } + + RefreshSmartTag(); + } + } + + public override DesignerActionListCollection ActionLists + { + get + { + if (actionLists is null) + { + BuildActionLists(); + } + + return actionLists; + } + } + + private ToolStripDropDownMenu BuildMenu(bool isRow) + { + ToolStripMenuItem add = new ToolStripMenuItem(); + ToolStripMenuItem insert = new ToolStripMenuItem(); + ToolStripMenuItem delete = new ToolStripMenuItem(); + ToolStripSeparator separator = new ToolStripSeparator(); + ToolStripLabel label = new ToolStripLabel(); + ToolStripMenuItem absolute = new ToolStripMenuItem(); + ToolStripMenuItem percent = new ToolStripMenuItem(); + ToolStripMenuItem autosize = new ToolStripMenuItem(); + + add.Text = SR.TableLayoutPanelDesignerAddMenu; + add.Tag = isRow; + add.Name = "add"; + add.Click += new System.EventHandler(this.OnAddClick); + + insert.Text = SR.TableLayoutPanelDesignerInsertMenu; + insert.Tag = isRow; + insert.Name = "insert"; + insert.Click += new System.EventHandler(this.OnInsertClick); + + delete.Text = SR.TableLayoutPanelDesignerDeleteMenu; + delete.Tag = isRow; + delete.Name = "delete"; + delete.Click += new System.EventHandler(this.OnDeleteClick); + + label.Text = SR.TableLayoutPanelDesignerLabelMenu; + if (SR.TableLayoutPanelDesignerDontBoldLabel == "0") + { + label.Font = new Font(label.Font, FontStyle.Bold); + } + + label.Name = "sizemode"; + + absolute.Text = SR.TableLayoutPanelDesignerAbsoluteMenu; + absolute.Tag = isRow; + absolute.Name = "absolute"; + absolute.Click += new System.EventHandler(this.OnAbsoluteClick); + + percent.Text = SR.TableLayoutPanelDesignerPercentageMenu; + percent.Tag = isRow; + percent.Name = "percent"; + percent.Click += new System.EventHandler(this.OnPercentClick); + + autosize.Text = SR.TableLayoutPanelDesignerAutoSizeMenu; + autosize.Tag = isRow; + autosize.Name = "autosize"; + autosize.Click += new System.EventHandler(this.OnAutoSizeClick); + + ToolStripDropDownMenu menu = new ToolStripDropDownMenu(); + menu.Items.AddRange(new ToolStripItem[] { add, insert, delete, separator, label, absolute, percent, autosize }); + menu.Tag = isRow; + menu.Opening += new System.ComponentModel.CancelEventHandler(this.OnRowColMenuOpening); + + IUIService uis = GetService(typeof(IUIService)) as IUIService; + if (uis is not null) + { + menu.Renderer = (ToolStripProfessionalRenderer)uis.Styles["VsRenderer"]; + if (uis.Styles["VsColorPanelText"] is Color) + { + menu.ForeColor = (Color)uis.Styles["VsColorPanelText"]; + } + } + + return menu; + } + + private void BuildActionLists() + { + actionLists = new DesignerActionListCollection(); + + // Add Column action list + actionLists.Add(new TableLayouPanelRowColumnActionList(this)); + + // if one actionList has AutoShow == true then the chrome panel will popup when the user DnD the DataGridView onto the form + // It would make sense to promote AutoShow to DesignerActionListCollection. + // But we don't own the DesignerActionListCollection so we just set AutoShow on the first ActionList + // + actionLists[0].AutoShow = true; + } + + private class TableLayouPanelRowColumnActionList : DesignerActionList + { + private TableLayoutPanelDesigner owner; + + public TableLayouPanelRowColumnActionList(TableLayoutPanelDesigner owner) : base(owner.Component) + { + this.owner = owner; + } + + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection items = new DesignerActionItemCollection(); + + // We don't promote these Items to DesignerVerbs, since we need to be able + // to disable/enable the Remove entries, based on the number of Rows/Cols. + // Unfortunately, you cannot do that via the DesignerAction stuff. + items.Add(new DesignerActionMethodItem(this, + "AddColumn", // method name + SR.TableLayoutPanelDesignerAddColumn, // display name + false)); // promoteToDesignerVerb + items.Add(new DesignerActionMethodItem(this, + "AddRow", // method name + SR.TableLayoutPanelDesignerAddRow, // display name + false)); // promoteToDesignerVerb + + if (owner.Table.ColumnCount > 1) + { + items.Add(new DesignerActionMethodItem(this, + "RemoveColumn", // method name + SR.TableLayoutPanelDesignerRemoveColumn, // display name + false)); // promoteToDesignerVerb + } + + if (owner.Table.RowCount > 1) + { + items.Add(new DesignerActionMethodItem(this, + "RemoveRow", // method name + SR.TableLayoutPanelDesignerRemoveRow, // display name + false)); // promoteToDesignerVerb + } + + items.Add(new DesignerActionMethodItem(this, + "EditRowAndCol", // method name + SR.TableLayoutPanelDesignerEditRowAndCol, // display name + false)); // promoteToDesignerVerb + + return items; + } + + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public void AddColumn() + { + this.owner.OnAdd(false); + } + + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public void AddRow() + { + this.owner.OnAdd(true); + } + + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public void RemoveColumn() + { + this.owner.OnRemove(false); + } + + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public void RemoveRow() + { + this.owner.OnRemove(true); + } + + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public void EditRowAndCol() + { + this.owner.OnEdit(); + } + } + + private void RemoveControlInternal(Control c) + { + Table.ControlRemoved -= new ControlEventHandler(this.OnControlRemoved); + Table.Controls.Remove(c); + Table.ControlRemoved += new ControlEventHandler(this.OnControlRemoved); + } + + private void AddControlInternal(Control c, int col, int row) + { + Table.ControlAdded -= new ControlEventHandler(this.OnControlAdded); + Table.Controls.Add(c, col, row); + Table.ControlAdded += new ControlEventHandler(this.OnControlAdded); + } + + [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] + [SuppressMessage("Microsoft.Security", "CA2102:CatchNonClsCompliantExceptionsInGeneralHandlers")] + private void ControlAddedInternal(Control control, Point newControlPosition, bool localReposition, bool fullTable, DragEventArgs de) + { + //If the table is full - we'll want to 'autogrow' either the row or column based on the grow style property + //before we actually add the control. + if (fullTable) + { + if (Table.GrowStyle == TableLayoutPanelGrowStyle.AddRows) + { + PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"]; + rowProp?.SetValue(Table, Table.GetRowHeights().Length); + + newControlPosition.X = 0; + newControlPosition.Y = Table.RowCount - 1; + } + else if (Table.GrowStyle == TableLayoutPanelGrowStyle.AddColumns) + { + PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"]; + colProp?.SetValue(Table, Table.GetColumnWidths().Length); + + newControlPosition.X = Table.ColumnCount - 1; + newControlPosition.Y = 0; + } + else + { + //fixed growstyle - what do we do here? + } + } + + DesignerTransaction trans = null; + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Table)["Controls"]; + //find the control that currently resides at our newControlPosition - we'll want to either + //remove it or swap it. + try + { + // Are we doing a local copy + bool localCopy = ((de is not null) && (de.Effect == DragDropEffects.Copy) && localReposition); + + Control existingControl = ((TableLayoutPanel)Control).GetControlFromPosition(newControlPosition.X, newControlPosition.Y); + + if (localCopy) + { + Debug.Assert(existingControl is null, "We shouldn't be able to do a local copy of a cell with an existing control"); + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + trans = host.CreateTransaction(string.Format(SR.BehaviorServiceCopyControl, control.Site.Name)); + } + + // Need to do this after the transaction is created + PropChanging(controlsProp); + } + + //does the newControlPosition contain a valid control + //if so - we need to perform a 'swap' function if this is local - or default + //to controls.add if this is from an external source + else if (existingControl is not null && !existingControl.Equals(control)) + { + if (localReposition) + { + // If we're swapping controls, create a DesignerTransaction + // so this can be undoable. + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + trans = host.CreateTransaction(string.Format(SR.TableLayoutPanelDesignerControlsSwapped, control.Site.Name, existingControl.Site.Name)); + } + + // Need to do this after the transaction is created + PropChanging(controlsProp); + RemoveControlInternal(existingControl);//we found our control to swap + } + else + { + //here we externally dragged a control onto a valid control in our table + //we'll try to find a place to put it (since we shouldn't be here if our table + //was full + + // MartinTh -- we shouldn't ever get here... + PropChanging(controlsProp); + existingControl = null;//null this out since we're not swapping + } + } + else + { + //here we have a truly empty cell + + // If we are not doing a local move, then the DropSourceBehavior created the transaction for us + if (localReposition) + { + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null) + { + trans = host.CreateTransaction(string.Format(SR.BehaviorServiceMoveControl, control.Site.Name)); + } + } + + existingControl = null; + PropChanging(controlsProp); + } + + //Need to do this after the transaction has been created + if (localCopy) + { + ArrayList temp = new ArrayList(); + temp.Add(control); + temp = DesignerUtils.CopyDragObjects(temp, Component.Site) as ArrayList; + control = temp[0] as Control; + } + + //if we are locally repositioning this control - remove it (internally) + //from the table's child collection and add something in its place. This + //will be a control to swap it with + if (localReposition) + { + Point oldPosition = GetControlPosition(control); + if (oldPosition != InvalidPoint) + { + RemoveControlInternal(control); + + if (oldPosition != newControlPosition) + {//guard against dropping it back on itself + if (existingControl is not null) + { + //we have something to swap... + AddControlInternal(existingControl, oldPosition.X, oldPosition.Y); + } + } + } + } + + //Finally - set our new control to the new position + if (localReposition) + { + //If we are doing a local drag, then the control previously got removed + AddControlInternal(control, newControlPosition.X, newControlPosition.Y); + } + else + { + //If not, then the control has already been added, and all we need to do is set the position + Table.SetCellPosition(control, new TableLayoutPanelCellPosition(newControlPosition.X, newControlPosition.Y)); + } + + PropChanged(controlsProp); + + if (de is not null) + { + base.OnDragComplete(de); + } + + if (trans is not null) + { + trans.Commit(); + trans = null; + } + + // Set the selection to be the newly added control - but only if we are doing a local copy + if (localCopy) + { + ISelectionService selSvc = GetService(typeof(ISelectionService)) as ISelectionService; + selSvc?.SetSelectedComponents(new object[] { control }, SelectionTypes.Primary | SelectionTypes.Replace); + } + } + + // VSWhidbey #390285 + catch (ArgumentException argumentEx) + { + IUIService uiService = GetService(typeof(IUIService)) as IUIService; + uiService?.ShowError(argumentEx); + } + + catch (Exception ex) + { + if (ClientUtils.IsCriticalException(ex)) + { + throw; + } + } + + finally + { + trans?.Cancel(); + } + } + + private void CreateEmptyTable() + { + //set the table's default rows and columns + PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"]; + colProp?.SetValue(Table, DesignerUtils.DEFAULTCOLUMNCOUNT); + + PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"]; + rowProp?.SetValue(Table, DesignerUtils.DEFAULTROWCOUNT); + + //this will make sure we have styles created for every row & column + EnsureAvailableStyles(); + + InitializeNewStyles(); + } + + private void InitializeNewStyles() + { + //adjust the two absolutely positioned columns + Table.ColumnStyles[0].SizeType = SizeType.Percent; + Table.ColumnStyles[0].Width = DesignerUtils.MINIMUMSTYLEPERCENT; + Table.ColumnStyles[1].SizeType = SizeType.Percent; + Table.ColumnStyles[1].Width = DesignerUtils.MINIMUMSTYLEPERCENT; + + //adjust two absolutely positioned rows + Table.RowStyles[0].SizeType = SizeType.Percent; + Table.RowStyles[0].Height = DesignerUtils.MINIMUMSTYLEPERCENT; + Table.RowStyles[1].SizeType = SizeType.Percent; + Table.RowStyles[1].Height = DesignerUtils.MINIMUMSTYLEPERCENT; + } + + /// + /// Returns true if an empty subset of size subsetColumns x subsetRows exists in the cells + /// array. cells[c,r] == true if the corresponding cell contains a control + /// + /// + /// + /// + /// + /// + /// + private static bool SubsetExists(bool[,] cells, int columns, int rows, int subsetColumns, int subsetRows) + { + bool exists = false; + int column = 0; + int row; + + for (row = 0; row < rows - subsetRows + 1; row++) + { + for (column = 0; column < columns - subsetColumns + 1; column++) + { + if (!cells[column, row]) + { + exists = true; + for (int m = row; (m < row + subsetRows) && exists; m++) + { + for (int n = column; n < column + subsetColumns; n++) + { + if (cells[n, m]) + { + exists = false; + break; + } + } + } + + if (exists) + { + break; + } + } + } + + if (exists) + { + break; + } + } + + return exists; + } + + protected internal override bool CanAddComponent(IComponent component) + { + if (Table.GrowStyle != TableLayoutPanelGrowStyle.FixedSize) + { + return true; + } + + Control newControl = GetControl(component); + if (newControl is null) + { + // this case should have been filtered out by CanParent + return false; + } + + int rowSpan = Table.GetRowSpan(newControl); + int columnSpan = Table.GetColumnSpan(newControl); + + // under certain conditions RowCount and ColumnCount are not accurate + int numRows = Table.GetRowHeights().Length; + int numColumns = Table.GetColumnWidths().Length; + int numOccupiedCells = 0; // total occupied cells in the TableLayoutPanel + + int totalCells = numRows * numColumns; + int cellsNeeded = rowSpan * columnSpan; + + // cache which cells have controls in them + bool[,] occupiedCells = null; + if (cellsNeeded > 1) + { + occupiedCells = new bool[numColumns, numRows]; + } + + if (cellsNeeded <= totalCells) + { + for (int row = 0; row < numRows; row++) + { + for (int column = 0; column < numColumns; column++) + { + if (Table.GetControlFromPosition(column, row) is not null) + { + numOccupiedCells++; + if (cellsNeeded > 1) + { + occupiedCells[column, row] = true; + } + } + } + } + } + + // Check if the table has enough empty cells to accomodate the new component + if (numOccupiedCells + cellsNeeded > totalCells) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(SR.TableLayoutPanelFullDesc); + + return false; + } + + // if the new control spans several rows or columns, check if the + // table has a contiguous free area to accomodate the control + if (cellsNeeded > 1) + { + if (!SubsetExists(occupiedCells, numColumns, numRows, columnSpan, rowSpan)) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(SR.TableLayoutPanelSpanDesc); + + return false; + } + } + + return true; + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + host.TransactionClosing -= new DesignerTransactionCloseEventHandler(this.OnTransactionClosing); + } + + if (undoEngine is not null) + { + if (Undoing) + { + undoEngine.Undone -= new EventHandler(this.OnUndone); + } + + undoEngine.Undoing -= new EventHandler(this.OnUndoing); + } + + if (compSvc is not null) + { + compSvc.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged); + compSvc.ComponentChanging -= new ComponentChangingEventHandler(this.OnComponentChanging); + } + + if (Table is not null) + { + Table.ControlAdded -= new ControlEventHandler(this.OnControlAdded); + Table.ControlRemoved -= new ControlEventHandler(this.OnControlRemoved); + } + + contextMenuRow?.Dispose(); + + contextMenuCol?.Dispose(); + + rowStyleProp = null; + colStyleProp = null; + } + + base.Dispose(disposing); + } + + protected override void DrawBorder(Graphics graphics) + { + if (Table.CellBorderStyle != TableLayoutPanelCellBorderStyle.None) + { + //only draw a fake border if there is no borderstyle. + return; + } + + base.DrawBorder(graphics); + + Rectangle rc = Control.DisplayRectangle; + rc.Width--; + rc.Height--; + + int[] cw = Table.GetColumnWidths(); + int[] rh = Table.GetRowHeights(); + + using (Pen pen = BorderPen) + { + if (cw.Length > 1) + { + bool isRTL = (Table.RightToLeft == RightToLeft.Yes); + // offset by padding + int startX = isRTL ? rc.Right : rc.Left; + for (int i = 0; i < cw.Length - 1; i++) + { + if (isRTL) + { + startX -= cw[i]; + } + else + { + startX += cw[i]; + } + + graphics.DrawLine(pen, startX, rc.Top, startX, rc.Bottom); + } + } + + if (rh.Length > 1) + { + int startY = rc.Top; + for (int i = 0; i < rh.Length - 1; i++) + { + startY += rh[i]; + graphics.DrawLine(pen, rc.Left, startY, rc.Right, startY); + } + } + } + } + + internal void SuspendEnsureAvailableStyles() + { + ensureSuspendCount++; + } + + internal void ResumeEnsureAvailableStyles(bool performEnsure) + { + if (ensureSuspendCount > 0) + { + ensureSuspendCount--; + + if (ensureSuspendCount == 0 && performEnsure) + { + EnsureAvailableStyles(); + } + } + } + + private bool EnsureAvailableStyles() + { + if (IsLoading || Undoing || ensureSuspendCount > 0) + { + return false; + } + + int[] cw = Table.GetColumnWidths(); + int[] rh = Table.GetRowHeights(); + + Table.SuspendLayout(); + try + { + //if we have more columns then column styles add some... + if (cw.Length > Table.ColumnStyles.Count) + { + int colDifference = cw.Length - Table.ColumnStyles.Count; + PropChanging(rowStyleProp); + for (int i = 0; i < colDifference; i++) + { + Table.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, DesignerUtils.MINIMUMSTYLESIZE)); + } + + PropChanged(rowStyleProp); + } + + //if we have more rows then row styles add some... + if (rh.Length > Table.RowStyles.Count) + { + int rowDifference = rh.Length - Table.RowStyles.Count; + PropChanging(colStyleProp); + for (int i = 0; i < rowDifference; i++) + { + Table.RowStyles.Add(new RowStyle(SizeType.Absolute, DesignerUtils.MINIMUMSTYLESIZE)); + } + + PropChanged(colStyleProp); + } + } + finally + { + Table.ResumeLayout(); + } + + return true; + } + + private Control ExtractControlFromDragEvent(DragEventArgs de) + { + DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject; + if (data is not null) + { + dragComps = new ArrayList(data.DragComponents); + return dragComps[0] as Control; + } + + return null; + } + + private Point GetCellPosition(Point pos) + { + //get some runtime table info + int[] rows = Table.GetRowHeights(); + int[] columns = Table.GetColumnWidths(); + + //By using DisplayRectangle here we handle the case where we are scrolled. VSWhidbey #399557 + Point startingPoint = Table.PointToScreen(Table.DisplayRectangle.Location); + Rectangle bounds = new Rectangle(startingPoint, Table.DisplayRectangle.Size); + + Point position = new Point(-1, -1); + + bool isRTL = Table.RightToLeft == RightToLeft.Yes; + int offset = bounds.X; + + // find column ... + if (isRTL) + { + if (pos.X <= bounds.X) + { // if pos.X >= bounds.Right, position.X = -1 + position.X = columns.Length; + } + else if (pos.X < bounds.Right) + { // it must be within the bounds + offset = bounds.Right; + + //loop through the columns and identify where the mouse is + for (int i = 0; i < columns.Length; i++) + { + position.X = i; + if (pos.X >= offset - columns[i]) + { + break; + } + + offset -= columns[i]; + } + } + } + else + { + if (pos.X >= bounds.Right) + { + position.X = columns.Length; + } + else if (pos.X > bounds.X) + { // if pos.X <= bounds.X, position.X = -1. + //loop through the columns and identify where the mouse is + for (int i = 0; i < columns.Length; i++) + { // it must be within the bounds + position.X = i; + if (pos.X <= offset + columns[i]) + { + break; + } + + offset += columns[i]; + } + } + } + + // find row ... + offset = bounds.Y; + + if (pos.Y >= bounds.Bottom) + { + position.Y = rows.Length; + } + else if (pos.Y > bounds.Y) + { // if pos.Y <= bounds.Y, position.Y = -1 + //loop through the rows and identify where the mouse is + for (int i = 0; i < rows.Length; i++) + { + if (pos.Y <= offset + rows[i]) + { + position.Y = i; + break; + } + + offset += rows[i]; + } + } + + return position; + } + + private Point GetControlPosition(Control control) + { + TableLayoutPanelCellPosition pos = Table.GetPositionFromControl(control); + if ((pos.Row == -1) && (pos.Column == -1)) + { + return InvalidPoint; + } + + return new Point(pos.Column, pos.Row); + } + + public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType) + { + GlyphCollection glyphs = base.GetGlyphs(selectionType); + + PropertyDescriptor prop = TypeDescriptor.GetProperties(Component)["Locked"]; + bool locked = (prop is not null) ? ((bool)prop.GetValue(Component)) : false; + + //Before adding glyphs for every row/column, make sure we have a column/rowstyle for every column/row + bool safeToRefresh = EnsureAvailableStyles(); + + //if we're somehow selected, not locked, and not inherited -then offer up glyphs for every + //column/row line + if (selectionType != GlyphSelectionType.NotSelected && !locked && InheritanceAttribute != InheritanceAttribute.InheritedReadOnly) + { + //get the correctly translated bounds + + //By using DisplayRectangle here we handle the case where we are scrolled. VSWhidbey #399689 + Point loc = BehaviorService.MapAdornerWindowPoint(Table.Handle, Table.DisplayRectangle.Location); + Rectangle bounds = new Rectangle(loc, Table.DisplayRectangle.Size); + + Point controlLoc = BehaviorService.ControlToAdornerWindow(Control); + Rectangle checkBounds = new Rectangle(controlLoc, Control.ClientSize); // Can't use Control.Size since that will include any scrollbar + + int[] cw = Table.GetColumnWidths(); + int[] rh = Table.GetRowHeights(); + int halfSize = DesignerUtils.RESIZEGLYPHSIZE / 2; + + bool isRTL = (Table.RightToLeft == RightToLeft.Yes); + int startLoc = isRTL ? bounds.Right : bounds.X; + + if (safeToRefresh) + { + //add resize glyphs for each column and row + for (int i = 0; i < cw.Length - 1; i++) + { + //Do not add a glyph for columns of 0 width. This can happen for percentage columns, where the table is not + //big enough for there to be any space for percentage columns + if (cw[i] == 0) + { + continue; + } + + if (isRTL) + { + startLoc -= cw[i]; + } + else + { + startLoc += cw[i];//x offset of column line + } + + Rectangle gBounds = new Rectangle(startLoc - halfSize, checkBounds.Top, DesignerUtils.RESIZEGLYPHSIZE, checkBounds.Height); + //Don't add glyphs for columns that are not within the clientrectangle. + if (!checkBounds.Contains(gBounds)) + { + continue; + } + + Debug.Assert(Table.ColumnStyles[i] is not null, "Table's ColumnStyle[" + i + "] is null!"); + if (Table.ColumnStyles[i] is not null) + { + TableLayoutPanelResizeGlyph g = new TableLayoutPanelResizeGlyph(gBounds, Table.ColumnStyles[i], Cursors.VSplit, Behavior); + glyphs.Add(g); + } + } + + startLoc = bounds.Y;//reset for the rows... + + for (int i = 0; i < rh.Length - 1; i++) + { + //Do not add a glyph for rows of 0 height. This can happen for percentage columns, where the table is not + //big enough for there to be any space for percentage columns + if (rh[i] == 0) + { + continue; + } + + startLoc += rh[i];//y offset of row line + Rectangle gBounds = new Rectangle(checkBounds.Left, startLoc - halfSize, checkBounds.Width, DesignerUtils.RESIZEGLYPHSIZE); + if (!checkBounds.Contains(gBounds)) + { + continue; + } + + Debug.Assert(Table.RowStyles[i] is not null, "Table's RowStyle[" + i + "] is null!"); + if (Table.RowStyles[i] is not null) + { + TableLayoutPanelResizeGlyph g = new TableLayoutPanelResizeGlyph(gBounds, Table.RowStyles[i], Cursors.HSplit, Behavior); + glyphs.Add(g); + } + } + } + } + + return glyphs; + } + + public override void Initialize(IComponent component) + { + base.Initialize(component); + + IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); + if (host is not null) + { + host.TransactionClosing += new DesignerTransactionCloseEventHandler(this.OnTransactionClosing); +#pragma warning disable VSSDK006 + compSvc = host.GetService(typeof(IComponentChangeService)) as IComponentChangeService; +#pragma warning restore VSSDK006 + } + + if (compSvc is not null) + { + compSvc.ComponentChanging += new ComponentChangingEventHandler(this.OnComponentChanging); + compSvc.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged); + } + + Control.ControlAdded += new ControlEventHandler(this.OnControlAdded); + Control.ControlRemoved += new ControlEventHandler(this.OnControlRemoved); + + rowStyleProp = TypeDescriptor.GetProperties(Table)["RowStyles"]; + colStyleProp = TypeDescriptor.GetProperties(Table)["ColumnStyles"]; + + // VSWhidbey #424845. If the TLP is inheritedreadonly, so should all of the children + if (InheritanceAttribute == InheritanceAttribute.InheritedReadOnly) + { + for (int i = 0; i < Control.Controls.Count; i++) + { + TypeDescriptor.AddAttributes(Control.Controls[i], InheritanceAttribute.InheritedReadOnly); + } + } + } + + protected override InheritanceAttribute InheritanceAttribute + { + get + { + if ((base.InheritanceAttribute == InheritanceAttribute.Inherited) + || (base.InheritanceAttribute == InheritanceAttribute.InheritedReadOnly)) + { + return InheritanceAttribute.InheritedReadOnly; + } + + return base.InheritanceAttribute; + } + } + + public override void InitializeNewComponent(IDictionary defaultValues) + { + base.InitializeNewComponent(defaultValues); + CreateEmptyTable(); + } + + protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize) + { + rowCountBeforeAdd = Math.Max(0, Table.GetRowHeights().Length); // don't want negative + colCountBeforeAdd = Math.Max(0, Table.GetColumnWidths().Length); + + return base.CreateToolCore(tool, x, y, width, height, hasLocation, hasSize); + } + + private void OnControlAdded(object sender, ControlEventArgs e) + { + if (IsLoading || Undoing) + { + return; + } + + // Calculate the number cells spanned by controls in the Table + // This can be slow, but it is the only way to really calculate the number of cells spanned. + // We cannot rely on checking the control's span since the TLP's growstyle might affect it. + // E.g. RowCount = ColumnCount = 2, GrowStyle = AddRows, button in cell(0,0), button.ColumnSpan = 6 + int totalArea = 0; + int[] rows = Table.GetRowHeights(); + int[] columns = Table.GetColumnWidths(); + + for (int row = 0; row < rows.Length; row++) + { + for (int column = 0; column < columns.Length; column++) + { + if (Table.GetControlFromPosition(column, row) is not null) + { + ++totalArea; + } + } + } + + //The control we are about to place, have already been added to the TLP's control collection, so -1 here. + //This is because we want to know if the table was full BEFORE the control was added. + + bool fullTable = (totalArea - 1) >= (Math.Max(1, colCountBeforeAdd) * Math.Max(1, rowCountBeforeAdd)); + + if (droppedCellPosition == InvalidPoint) + { + droppedCellPosition = GetControlPosition(e.Control); + } + + Debug.Assert(fullTable || (droppedCellPosition != InvalidPoint), "Why is neither fullTable or droppedCellPosition set?"); + + ControlAddedInternal(e.Control, droppedCellPosition, false, fullTable, null); + + droppedCellPosition = InvalidPoint; + } + + private void OnControlRemoved(object sender, ControlEventArgs e) + { + // Need to do this to make sure undo/redo works + // Since the Row/Col extended property is DesignerSerializationVisibility.Hidden, the undo engine + // will not serialize the value out, so we need to reset it here. VSWhidbey #392705. + if (e is not null && e.Control is not null) + { + Table.SetCellPosition(e.Control, new TableLayoutPanelCellPosition(-1, -1)); + } + } + + private bool IsOverValidCell(bool dragOp) + { + Point dropPoint = GetCellPosition(Control.MousePosition); + + // check if cell position is valid. + int[] rows = Table.GetRowHeights(); + int[] columns = Table.GetColumnWidths(); + + if (dropPoint.Y < 0 || dropPoint.Y >= rows.Length || dropPoint.X < 0 || dropPoint.X >= columns.Length) + { + return false; + } + + if (dragOp) + { + Control existingControl = (Control)((TableLayoutPanel)Control).GetControlFromPosition(dropPoint.X, dropPoint.Y); + + //If the cell is not empty, and we are not doing a local drag, then show the no-smoking cursor + //or if we are doing a multi-select local drag, then show the no-smoking cursor. + //or if we are doig a local drag, and the cell is not empty, and we are doing a copy + if ((existingControl is not null && localDragControl is null) || + (localDragControl is not null && dragComps.Count > 1) || + (localDragControl is not null && existingControl is not null && Control.ModifierKeys == Keys.Control)) + { + return false; + } + } + + return true; + } + + protected override void OnContextMenu(int x, int y) + { + Point cell = GetCellPosition(new Point(x, y)); + + curRow = cell.Y; + curCol = cell.X; + + //Set the SizeMode correctly + EnsureAvailableStyles(); + + DesignerContextMenuStrip.Show(x, y); + } + + protected override void OnDragEnter(DragEventArgs de) + { + base.OnDragEnter(de); + + //peak at what just entered her e- it it's a local control + //we'll cache it off + if (localDragControl is null) + { + Control dragControl = ExtractControlFromDragEvent(de); + if (dragControl is not null && Table.Controls.Contains(dragControl)) + { + localDragControl = dragControl; + } + } + } + + protected override void OnDragLeave(EventArgs e) + { + localDragControl = null; //VSWhidbey #275678 + dragComps = null; + base.OnDragLeave(e); + } + + protected override void OnDragDrop(DragEventArgs de) + { + droppedCellPosition = GetCellPosition(Control.MousePosition); + + //the scenario where we just dropped our own child control + if (localDragControl is not null) + { + //local drag to our TLP - we need to re-insert or swap it... + ControlAddedInternal(localDragControl, droppedCellPosition, true, false, de); + localDragControl = null; + } + else + { + rowCountBeforeAdd = Math.Max(0, Table.GetRowHeights().Length); // don't want negative + colCountBeforeAdd = Math.Max(0, Table.GetColumnWidths().Length); + + //If from the outside, just let the base class handle it + base.OnDragDrop(de); + + // VSWhidbey #390230 + // Devdiv Bugs 40804 + // This will not fix VSWhidbey #390230 in the copy/paste scenario but it will for the + // main drag/drop scneario. + // We need to do this after the controls are added (after base.OnDragDrop above) + // because Span is an "attached" property which is not available unless the control is parented to + // a table. However in the case when the table is full and can't grow, setting control's + // span after the Add is too late, because the runtime had already thrown an exception. + // Unfortunally cancelling the transaction throws as well, so we need a way to undo the Add + // or access internal properties of the control. + + // dragComps is null when dragging off the toolbox + if (dragComps is not null) + { + foreach (Control dragControl in dragComps) + { + if (dragControl is not null) + { + PropertyDescriptor columnSpan = TypeDescriptor.GetProperties(dragControl)["ColumnSpan"]; + PropertyDescriptor rowSpan = TypeDescriptor.GetProperties(dragControl)["RowSpan"]; + columnSpan?.SetValue(dragControl, 1); + + rowSpan?.SetValue(dragControl, 1); + } + } + } + } + + droppedCellPosition = InvalidPoint; + dragComps = null; + } + + protected override void OnDragOver(DragEventArgs de) + { + // If we are not over a valid cell, then do not allow the drop + if (!IsOverValidCell(true)) + { + de.Effect = DragDropEffects.None; + return; + } + + base.OnDragOver(de); + } + + private Dictionary extenderProperties; + + private Dictionary ExtenderProperties + { + get + { + if (extenderProperties is null && Component is not null) + { + extenderProperties = new Dictionary(); + + AttributeCollection attribs = TypeDescriptor.GetAttributes(Component.GetType()); + + foreach (Attribute a in attribs) + { + ProvidePropertyAttribute extender = a as ProvidePropertyAttribute; + if (extender is not null) + { + extenderProperties[extender.PropertyName] = true; + } + } + } + + return extenderProperties; + } + } + + private bool DoesPropertyAffectPosition(MemberDescriptor member) + { + bool affectsPosition = false; + DesignerSerializationVisibilityAttribute dsv = member.Attributes[typeof(DesignerSerializationVisibilityAttribute)] as DesignerSerializationVisibilityAttribute; + if (dsv is not null) + { + affectsPosition = dsv.Visibility == DesignerSerializationVisibility.Hidden && ExtenderProperties.ContainsKey(member.Name); + } + + return affectsPosition; + } + + private void OnComponentChanging(object sender, ComponentChangingEventArgs e) + { + Control changingControl = e.Component as Control; + + if (changingControl is not null && changingControl.Parent == this.Component && + e.Member is not null && DoesPropertyAffectPosition(e.Member)) + { + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Component)["Controls"]; + compSvc.OnComponentChanging(Component, controlsProp); + } + } + + private void OnComponentChanged(object sender, ComponentChangedEventArgs e) + { + //VSWhidbey 233871 + // + //When the Row or Column property is being set on a control in the TLP, a Row/Col Style is not being added. + //After the property is being set, the SelectionManager::OnSelectionChanged gets called. It in turn calls + //GetGlyphs, and the TLP designer's GetGlyphs calls EnsureAvaiableStyles. Since no style was added, we will add + //a default one of type Absolute, Height/Width 20. But but but... If the control has added its glyph before we + //add the style, the glyphs wil be misaligned, since EnsureAvailableStyles also causes the TLP to do a layout. This + //layout will actually size the control to a smaller size. So let's trap the Row/Col property changing, call + //EnsureAvailableStyles, which will force the layout BEFORE the SelectionManager is called. + if (e.Component is not null) + { + Control c = e.Component as Control; + if (c is not null && c.Parent is not null && c.Parent.Equals(Control) && e.Member is not null && (e.Member.Name == "Row" || e.Member.Name == "Column")) + { + EnsureAvailableStyles(); + } + + if (c is not null && c.Parent == this.Component && + e.Member is not null && DoesPropertyAffectPosition(e.Member)) + { + PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Component)["Controls"]; + compSvc.OnComponentChanged(Component, controlsProp, null, null); + } + } + + CheckVerbStatus(); + } + + private void OnTransactionClosing(object sender, DesignerTransactionCloseEventArgs e) + { + ISelectionService selSvc = GetService(typeof(ISelectionService)) as ISelectionService; + if (selSvc is not null && Table is not null) + { + ICollection selectedComps = selSvc.GetSelectedComponents(); + bool selectedComponentHasTableParent = false; + foreach (object comp in selectedComps) + { + Control c = comp as Control; + if (c is not null && c.Parent == Table) + { + selectedComponentHasTableParent = true; + break; + } + } + + if (selSvc.GetComponentSelected(Table) || selectedComponentHasTableParent) + { + //force an internal 'onlayout' event to refresh our control + Table.SuspendLayout(); + EnsureAvailableStyles(); + Table.ResumeLayout(false); + Table.PerformLayout(); + } + } + } + + private void OnUndoing(object sender, EventArgs e) + { + if (!Undoing) + { + if (undoEngine is not null) + { + undoEngine.Undone += new EventHandler(this.OnUndone); + } + + Undoing = true; + } + } + + private void OnUndone(object sender, EventArgs e) + { + if (Undoing) + { + if (undoEngine is not null) + { + undoEngine.Undone -= new EventHandler(this.OnUndone); + } + + Undoing = false; + + bool isSafeToRefresh = EnsureAvailableStyles(); + + if (isSafeToRefresh) + { + Refresh(); + } + } + } + + protected override void OnMouseDragBegin(int x, int y) + { + if (IsOverValidCell(true)) + { + //make sure we have a valid toolbox item and we're not just drawing a rect + IToolboxService tbx = (IToolboxService)GetService(typeof(IToolboxService)); + if (tbx is not null && tbx.GetSelectedToolboxItem((IDesignerHost)GetService(typeof(IDesignerHost))) is not null) + { + droppedCellPosition = GetCellPosition(Control.MousePosition); + } + } + else + { + droppedCellPosition = InvalidPoint; + Cursor.Current = Cursors.No; + } + + base.OnMouseDragBegin(x, y); + } + + protected override void OnMouseDragMove(int x, int y) + { + //If they are trying to draw in a cell that already has a control, then we + //do not want to draw an outline + if (droppedCellPosition == InvalidPoint) + { + Cursor.Current = Cursors.No; + return; + } + + base.OnMouseDragMove(x, y); + } + + protected override void OnMouseDragEnd(bool cancel) + { + if (droppedCellPosition == InvalidPoint) + { + // If they are trying to draw in a cell that already has a control, then just act like a cancel + cancel = true; + } + + base.OnMouseDragEnd(cancel); + } + + private void OnRowColMenuOpening(object sender, CancelEventArgs e) + { + e.Cancel = false; + //Set the size mode correctly + ToolStripDropDownMenu menu = sender as ToolStripDropDownMenu; + if (menu is not null) + { + int selCount = 0; + ISelectionService selSvc = GetService(typeof(ISelectionService)) as ISelectionService; + if (selSvc is not null) + { + selCount = selSvc.SelectionCount; + } + + // Always make sure and set the Enabled state in case the user + // has changed the selection since the last time the menu was shown. + bool enabled = (selCount == 1) && (InheritanceAttribute != InheritanceAttribute.InheritedReadOnly); + + menu.Items["add"].Enabled = enabled; + menu.Items["insert"].Enabled = enabled; + menu.Items["delete"].Enabled = enabled; + menu.Items["sizemode"].Enabled = enabled; + menu.Items["absolute"].Enabled = enabled; + menu.Items["percent"].Enabled = enabled; + menu.Items["autosize"].Enabled = enabled; + + if (selCount == 1) + { + ((ToolStripMenuItem)menu.Items["absolute"]).Checked = false; + ((ToolStripMenuItem)menu.Items["percent"]).Checked = false; + ((ToolStripMenuItem)menu.Items["autosize"]).Checked = false; + + bool isRow = (bool)menu.Tag; + switch (isRow ? Table.RowStyles[curRow].SizeType : Table.ColumnStyles[curCol].SizeType) + { + case SizeType.Absolute: + ((ToolStripMenuItem)menu.Items["absolute"]).Checked = true; + break; + case SizeType.Percent: + ((ToolStripMenuItem)menu.Items["percent"]).Checked = true; + break; + case SizeType.AutoSize: + ((ToolStripMenuItem)menu.Items["autosize"]).Checked = true; + break; + default: + Debug.Fail("Unknown SizeType!"); + break; + } + + if ((isRow ? Table.RowCount : Table.ColumnCount) < 2) + { + //can't remove a row/column if we only have + menu.Items["delete"].Enabled = false; + } + } + } + } + + private void OnAdd(bool isRow) + { + // get the property and add to it... + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null && Table.Site is not null) + { + using (DesignerTransaction t = host.CreateTransaction(string.Format(isRow ? SR.TableLayoutPanelDesignerAddRowUndoUnit : + SR.TableLayoutPanelDesignerAddColumnUndoUnit, Table.Site.Name))) + { + try + { + Table.SuspendLayout(); // To avoid flickering + // This ensures that the Row/Col Style gets set BEFORE the row is added. This in turn + // ensures that the row/col shows up. Since we turn off tablelayout, a style won't have been added + // when EnsureVisibleStyles is called from the shadowed property. + InsertRowCol(isRow, isRow ? Table.RowCount : Table.ColumnCount); + Table.ResumeLayout(); + t.Commit(); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + t?.Cancel(); + } + else + { + throw; + } + } + } + } + } + + private void OnAddClick(object sender, EventArgs e) + { + //Tag = isRow + OnAdd((bool)((ToolStripMenuItem)sender).Tag); + } + + internal void InsertRowCol(bool isRow, int index) + { + // We shadow the ColumnCount/RowCount property, so let's add the style first + // to make sure that the right style is added at the right location. + try + { + if (isRow) + { + PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"]; + if (rowProp is not null) + { + PropChanging(rowStyleProp); + Table.RowStyles.Insert(index, new RowStyle(SizeType.Absolute, DesignerUtils.MINIMUMSTYLESIZE)); + PropChanged(rowStyleProp); + + rowProp.SetValue(Table, Table.RowCount + 1); + } + } + else + { + PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"]; + if (colProp is not null) + { + PropChanging(colStyleProp); + Table.ColumnStyles.Insert(index, new ColumnStyle(SizeType.Absolute, DesignerUtils.MINIMUMSTYLESIZE)); + PropChanged(colStyleProp); + + colProp.SetValue(Table, Table.ColumnCount + 1); + } + } + } + catch (System.InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + + // VSWhidbey # 490635 + BehaviorService.Invalidate(BehaviorService.ControlRectInAdornerWindow(Control)); + } + + internal void FixUpControlsOnInsert(bool isRow, int index) + { + PropertyDescriptor childProp = TypeDescriptor.GetProperties(Table)["Controls"]; + PropChanging(childProp); + + foreach (Control child in Table.Controls) + { + int currentIndex = isRow ? Table.GetRow(child) : Table.GetColumn(child); + PropertyDescriptor prop = TypeDescriptor.GetProperties(child)[isRow ? "Row" : "Column"]; + PropertyDescriptor spanProp = TypeDescriptor.GetProperties(child)[isRow ? "RowSpan" : "ColumnSpan"]; + + if (currentIndex == -1) + { + //this is a flow element. We don't really know where + //this is going to go, so we cannot fix up anything. + continue; + } + + //push all controls >= the original row/col into the new row/col + if (currentIndex >= index) + { + prop?.SetValue(child, currentIndex + 1); + } + else + { + //If the control is before the row/col we are inserting and the control has a span that includes the inserted row/col + //the increase the span to include the insert row/col + int span = isRow ? Table.GetRowSpan(child) : Table.GetColumnSpan(child); //span is always at least 1 + if (currentIndex + span > index) + { + spanProp?.SetValue(child, span + 1); + } + } + } + + PropChanged(childProp); + } + + private void OnInsertClick(object sender, EventArgs e) + { + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null && Table.Site is not null) + { + bool isRow = (bool)((ToolStripMenuItem)sender).Tag; + using (DesignerTransaction t = host.CreateTransaction(string.Format(isRow ? SR.TableLayoutPanelDesignerAddRowUndoUnit : + SR.TableLayoutPanelDesignerAddColumnUndoUnit, Table.Site.Name))) + { + try + { + Table.SuspendLayout(); + InsertRowCol(isRow, isRow ? curRow : curCol); + FixUpControlsOnInsert(isRow, isRow ? curRow : curCol); + Table.ResumeLayout(); + t.Commit(); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + t?.Cancel(); + } + else + { + throw; + } + } + catch (System.InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + } + } + } + + internal void FixUpControlsOnDelete(bool isRow, int index, ArrayList deleteList) + { + PropertyDescriptor childProp = TypeDescriptor.GetProperties(Table)["Controls"]; + PropChanging(childProp); + + foreach (Control child in Table.Controls) + { + int currentIndex = isRow ? Table.GetRow(child) : Table.GetColumn(child); + PropertyDescriptor prop = TypeDescriptor.GetProperties(child)[isRow ? "Row" : "Column"]; + PropertyDescriptor spanProp = TypeDescriptor.GetProperties(child)[isRow ? "RowSpan" : "ColumnSpan"]; + + if (currentIndex == index) + { + //We add the deleteList.Contains check just to make extra sure. Could be + //that the deleteList for some reason already contained the child. + if (!deleteList.Contains(child)) + { + deleteList.Add(child); + } + + continue; + } + + if (currentIndex == -1 || deleteList.Contains(child)) + { + //If this is a flow element. We don't really know where this is going to go, so we cannot fix up anything. + //If the child has already been marked for deletion, we can keep going + continue; + } + + Debug.Assert(currentIndex != index); + + //push all controls >= the original row/col into the new row/col, but only + if (currentIndex > index) + { + prop?.SetValue(child, currentIndex - 1); + } + else + { + //If the control is before the row/col we are removing and the control has a span that includes the row/col + //we are deleting, then decrease the span. + int span = isRow ? Table.GetRowSpan(child) : Table.GetColumnSpan(child); //span is always at least 1 + if (currentIndex + span > index) + { + //We've bled into the row/col, shrink up as expected + spanProp?.SetValue(child, span - 1); + } + } + } + + PropChanged(childProp); + } + + internal void DeleteRowCol(bool isRow, int index) + { + if (isRow) + { + PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"]; + if (rowProp is not null) + { + rowProp.SetValue(Table, Table.RowCount - 1); + + PropChanging(rowStyleProp); + Table.RowStyles.RemoveAt(index); + PropChanged(rowStyleProp); + } + } + else + { + PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"]; + if (colProp is not null) + { + colProp.SetValue(Table, Table.ColumnCount - 1); + + PropChanging(colStyleProp); + Table.ColumnStyles.RemoveAt(index); + PropChanged(colStyleProp); + } + } + } + + private void OnRemoveInternal(bool isRow, int index) + { + if ((isRow ? Table.RowCount : Table.ColumnCount) < 2) + { + //can't remove a row/column if we only have 1 + return; + } + + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null && Table.Site is not null) + { + using (DesignerTransaction t = host.CreateTransaction(string.Format(isRow ? SR.TableLayoutPanelDesignerRemoveRowUndoUnit : + SR.TableLayoutPanelDesignerRemoveColumnUndoUnit, Table.Site.Name))) + { + try + { + Table.SuspendLayout(); + ArrayList deleteList = new ArrayList(); + + //First fix up any controls in the row/col we are deleting + FixUpControlsOnDelete(isRow, index, deleteList); + //Then delete the row col + DeleteRowCol(isRow, index); + + //Now delete any child control + + // IF YOU CHANGE THIS, YOU SHOULD ALSO CHANGE THE CODE IN StyleCollectionEditor.OnOkButtonClick + if (deleteList.Count > 0) + { + PropertyDescriptor childProp = TypeDescriptor.GetProperties(Table)["Controls"]; + PropChanging(childProp); + foreach (object o in deleteList) + { + ArrayList al = new ArrayList(); + DesignerUtils.GetAssociatedComponents((IComponent)o, host, al); + foreach (IComponent comp in al) + { + compSvc.OnComponentChanging(comp, null); + } + + host.DestroyComponent(o as Component); + } + + PropChanged(childProp); + } + + Table.ResumeLayout(); + t.Commit(); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + t?.Cancel(); + } + else + { + throw; + } + } + } + } + } + + private void OnRemove(bool isRow) + { + OnRemoveInternal(isRow, isRow ? Table.RowCount - 1 : Table.ColumnCount - 1); + } + + private void OnDeleteClick(object sender, EventArgs e) + { + try + { + bool isRow = (bool)((ToolStripMenuItem)sender).Tag; + OnRemoveInternal(isRow, isRow ? curRow : curCol); + } + catch (System.InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + } + + private void ChangeSizeType(bool isRow, SizeType newType) + { + TableLayoutStyleCollection styles = null; + try + { + if (isRow) + { + styles = Table.RowStyles; + } + else + { + styles = Table.ColumnStyles; + } + + int index = isRow ? curRow : curCol; + + if (styles[index].SizeType == newType) + { + // nuthin' to do + return; + } + + int[] rh = Table.GetRowHeights(); + int[] ch = Table.GetColumnWidths(); + + if ((isRow && rh.Length < index - 1) || (!isRow && ch.Length < index - 1)) + { + //something got messed up + Debug.Fail("Our indices are outta whack, how did that happen?"); + return; + } + + IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; + if (host is not null && Table.Site is not null) + { + using (DesignerTransaction t = host.CreateTransaction(string.Format(SR.TableLayoutPanelDesignerChangeSizeTypeUndoUnit, Table.Site.Name))) + { + try + { + Table.SuspendLayout(); + + PropChanging(isRow ? rowStyleProp : colStyleProp); + + switch (newType) + { + case SizeType.Absolute: + styles[index].SizeType = SizeType.Absolute; + if (isRow) + { + Table.RowStyles[index].Height = rh[index]; + } + else + { + Table.ColumnStyles[index].Width = ch[index]; + } + + break; + case SizeType.Percent: + styles[index].SizeType = SizeType.Percent; + if (isRow) + { + Table.RowStyles[index].Height = DesignerUtils.MINIMUMSTYLEPERCENT; + } + else + { + Table.ColumnStyles[index].Width = DesignerUtils.MINIMUMSTYLEPERCENT; + } + + break; + case SizeType.AutoSize: + styles[index].SizeType = SizeType.AutoSize; + break; + default: + Debug.Fail("Unknown SizeType!"); + break; + } + + PropChanged(isRow ? rowStyleProp : colStyleProp); + + Table.ResumeLayout(); + t.Commit(); + } + catch (CheckoutException checkoutException) + { + if (CheckoutException.Canceled.Equals(checkoutException)) + { + t?.Cancel(); + } + else + { + throw; + } + } + } + } + } + catch (System.InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + } + + private void OnAbsoluteClick(object sender, EventArgs e) + { + ChangeSizeType((bool)((ToolStripMenuItem)sender).Tag, SizeType.Absolute); + } + + private void OnPercentClick(object sender, EventArgs e) + { + ChangeSizeType((bool)((ToolStripMenuItem)sender).Tag, SizeType.Percent); + } + + private void OnAutoSizeClick(object sender, EventArgs e) + { + ChangeSizeType((bool)((ToolStripMenuItem)sender).Tag, SizeType.AutoSize); + } + + private void OnEdit() + { + try + { + EditorServiceContext.EditValue(this, Table, "ColumnStyles"); + } + catch (System.InvalidOperationException ex) + { + IUIService uiService = (IUIService)GetService(typeof(IUIService)); + uiService.ShowError(ex.Message); + } + } + + private static string ReplaceText(string text) + { + return text is null ? null : Regex.Replace(text, @"\(\&.\)", ""); + } + + private void OnVerbRemove(object sender, EventArgs e) + { + //sniff the text of the verb to see if we're adding columns or rows + bool isRow = ((DesignerVerb)sender).Text.Equals(ReplaceText(SR.TableLayoutPanelDesignerRemoveRow)); + OnRemove(isRow); + } + + private void OnVerbAdd(object sender, EventArgs e) + { + //sniff the text of the verb to see if we're adding columns or rows + bool isRow = ((DesignerVerb)sender).Text.Equals(ReplaceText(SR.TableLayoutPanelDesignerAddRow)); + OnAdd(isRow); + } + + private void OnVerbEdit(object sender, EventArgs e) + { + OnEdit(); + } + + protected override void PreFilterProperties(IDictionary properties) + { + base.PreFilterProperties(properties); + + // Handle shadowed properties + string[] shadowProps = new string[] + { + "ColumnStyles", + "RowStyles", + "ColumnCount", + "RowCount" + }; + + // VSWhidbey 491088 + // To enable the PropertyGrid to work with the TableLayoutPanel at runtime (when no designer is available), + // the above properties are marked browsable(false) and re-enabled when a designer is present. + // Since so much of the logic for keeping the TLP in a valid Row/Column state is designer dependent, + // these properties are not accessible by the PropertyGrid without a designer. + Attribute[] attribs = new Attribute[] { new BrowsableAttribute(true) }; + + for (int i = 0; i < shadowProps.Length; i++) + { + PropertyDescriptor prop = (PropertyDescriptor)properties[shadowProps[i]]; + if (prop is not null) + { + properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(TableLayoutPanelDesigner), prop, attribs); + } + } + + // replace this one seperately because it is of a different type (DesignerTableLayoutControlCollection) than + // the original property (TableLayoutControlCollection) + // + PropertyDescriptor controlsProp = (PropertyDescriptor)properties["Controls"]; + + if (controlsProp is not null) + { + Attribute[] attrs = new Attribute[controlsProp.Attributes.Count]; + controlsProp.Attributes.CopyTo(attrs, 0); + properties["Controls"] = TypeDescriptor.CreateProperty(typeof(TableLayoutPanelDesigner), "Controls", typeof(DesignerTableLayoutControlCollection), attrs); + } + } + + private void Refresh() + { + //refresh selection, glyphs, and adorners + BehaviorService.SyncSelection(); + + Table?.Invalidate(true); + } + + private void PropChanging(PropertyDescriptor prop) + { + if (compSvc is not null && prop is not null) + { + compSvc.OnComponentChanging(Table, prop); + } + } + + private void PropChanged(PropertyDescriptor prop) + { + if (compSvc is not null && prop is not null) + { + compSvc.OnComponentChanged(Table, prop, null, null); + } + } + + [ListBindable(false)] + [DesignerSerializer(typeof(DesignerTableLayoutControlCollectionCodeDomSerializer), typeof(CodeDomSerializer))] + internal class DesignerTableLayoutControlCollection : TableLayoutControlCollection, IList + { + private TableLayoutControlCollection realCollection; + + public DesignerTableLayoutControlCollection(TableLayoutPanel owner) : base(owner) + { + this.realCollection = owner.Controls; + } + + public override int Count + { + get + { + return realCollection.Count; + } + } + + object ICollection.SyncRoot + { + get + { + return this; + } + } + + bool ICollection.IsSynchronized + { + get + { + return false; + } + } + + bool IList.IsFixedSize + { + get + { + return false; + } + } + + public new bool IsReadOnly + { + get + { + return realCollection.IsReadOnly; + } + } + + int IList.Add(object control) + { + return ((IList)realCollection).Add(control); + } + + public override void Add(Control c) + { + realCollection.Add(c); + } + + public override void AddRange(Control[] controls) + { + realCollection.AddRange(controls); + } + + bool IList.Contains(object control) + { + return ((IList)realCollection).Contains(control); + } + + public new void CopyTo(Array dest, int index) + { + realCollection.CopyTo(dest, index); + } + + public override bool Equals(object other) + { + return realCollection.Equals(other); + } + + public new IEnumerator GetEnumerator() + { + return realCollection.GetEnumerator(); + } + + public override int GetHashCode() + { + return realCollection.GetHashCode(); + } + + int IList.IndexOf(object control) + { + return ((IList)realCollection).IndexOf(control); + } + + void IList.Insert(int index, object value) + { + ((IList)realCollection).Insert(index, value); + } + + void IList.Remove(object control) + { + ((IList)realCollection).Remove(control); + } + + void IList.RemoveAt(int index) + { + ((IList)realCollection).RemoveAt(index); + } + + object IList.this[int index] + { + get + { + return ((IList)realCollection)[index]; + } + set + { + throw new NotSupportedException(); + } + } + + public override void Add(Control control, int column, int row) + { + realCollection.Add(control, column, row); + } + + public override int GetChildIndex(Control child, bool throwException) + { + return realCollection.GetChildIndex(child, throwException); + } + + public override void SetChildIndex(Control child, int newIndex) + { + realCollection.SetChildIndex(child, newIndex); + } + + public override void Clear() + { + // only remove the sited non-inherited components + for (int i = realCollection.Count - 1; i >= 0; i--) + { + if (realCollection[i] is not null && + realCollection[i].Site is not null && + TypeDescriptor.GetAttributes(realCollection[i]).Contains(InheritanceAttribute.NotInherited)) + { + realCollection.RemoveAt(i); + } + } + } + } + + // Custom code dom serializer for the DesignerControlCollection. We need this so we can filter out controls + // that aren't sited in the host's container. + internal class DesignerTableLayoutControlCollectionCodeDomSerializer : TableLayoutControlCollectionCodeDomSerializer + { + protected override object SerializeCollection(IDesignerSerializationManager manager, CodeExpression targetExpression, Type targetType, ICollection originalCollection, ICollection valuesToSerialize) + { + ArrayList subset = new ArrayList(); + + if (valuesToSerialize is not null && valuesToSerialize.Count > 0) + { + foreach (object val in valuesToSerialize) + { + IComponent comp = val as IComponent; + + if (comp is not null && comp.Site is not null && !(comp.Site is INestedSite)) + { + subset.Add(comp); + } + } + } + + return base.SerializeCollection(manager, targetExpression, targetType, originalCollection, subset); + } + } +} diff --git a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ClientUtils.cs b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ClientUtils.cs index 65233e14ad1..e728363f8c2 100644 --- a/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ClientUtils.cs +++ b/src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ClientUtils.cs @@ -48,4 +48,21 @@ public static int GetWordBoundaryStart(string text, int endIndex) return index + 1; } + + // ExecutionEngineException is obsolete and shouldn't be used (to catch, throw or reference) anymore. + // Pragma added to prevent converting the "type is obsolete" warning into build error. + // File owner should fix this. + #pragma warning disable 618 + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public static bool IsCriticalException(Exception ex) + { + return ex is NullReferenceException + || ex is StackOverflowException + || ex is OutOfMemoryException + || ex is System.Threading.ThreadAbortException + || ex is ExecutionEngineException + || ex is IndexOutOfRangeException + || ex is AccessViolationException; + } + #pragma warning restore 618 } diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs index c9a92ea3c9a..fa20d617056 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.Designer.cs @@ -1,4 +1,4 @@ -namespace TestConsole; +namespace TestConsole; partial class MainForm { /// @@ -31,6 +31,7 @@ private void InitializeComponent() { this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.tabPage4 = new System.Windows.Forms.TabPage(); + this.tabPage5 = new System.Windows.Forms.TabPage(); this.propertyGrid = new System.Windows.Forms.PropertyGrid(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -79,6 +80,7 @@ private void InitializeComponent() { this.tabControl1.Controls.Add( this.tabPage2 ); this.tabControl1.Controls.Add( this.tabPage3 ); this.tabControl1.Controls.Add( this.tabPage4 ); + this.tabControl1.Controls.Add( this.tabPage5 ); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point( 0, 0 ); this.tabControl1.Name = "tabControl1"; @@ -126,6 +128,16 @@ private void InitializeComponent() { this.tabPage4.Text = "tabPage4"; this.tabPage4.UseVisualStyleBackColor = true; // + // tabPage5 + // + this.tabPage5.Location = new System.Drawing.Point(4, 25); + this.tabPage5.Name = "tabPage5"; + this.tabPage5.Padding = new System.Windows.Forms.Padding(3); + this.tabPage5.Size = new System.Drawing.Size(585, 473); + this.tabPage5.TabIndex = 3; + this.tabPage5.Text = "tabPage5"; + this.tabPage5.UseVisualStyleBackColor = true; + // // propertyGrid // this.propertyGrid.Dock = System.Windows.Forms.DockStyle.Fill; @@ -302,6 +314,7 @@ private void InitializeComponent() { private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage tabPage3; private System.Windows.Forms.TabPage tabPage4; +private System.Windows.Forms.TabPage tabPage5; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTools; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTabOrder; diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs index 48574a235ee..3e37e45e5c3 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs @@ -24,11 +24,13 @@ private void InitFormDesigner() CreateDesignSurface(2); CreateDesignSurface(3); CreateDesignSurface(4); + CreateDesignSurface(5); tabPage1.Text = "Use SnapLines"; tabPage2.Text = "Use Grid (Snap to the grid)"; tabPage3.Text = "Use Grid"; tabPage4.Text = "Align control by hand"; + tabPage5.Text = "TabControl and TabLayoutPanel"; //- enable the UndoEngines for (int i = 0; i < tabControl1.TabCount; i++) @@ -90,6 +92,9 @@ private void CreateDesignSurface(int n) case 4: surface.UseNoGuides(); break; + case 5: + surface.UseNoGuides(); + break; default: Console.WriteLine("Invalid selection"); break; @@ -219,6 +224,18 @@ private void CreateDesignSurface(int n) FontDialog fd1 = surface.CreateComponent(); } + break; + case 5: + { + rootComponent = surface.CreateRootComponent(new Size(800, 600)); + rootComponent.BackColor = Color.Orange; + rootComponent.Text = "Root Component hosted by the DesignSurface N.5"; + + surface.CreateControl(new Size(400, 100), new Point(12, 21)); + + surface.CreateControl(new Size(290, 160), new Point(20, 220)); + } + break; default: Console.WriteLine("Invalid selection"); @@ -250,6 +267,9 @@ private void CreateDesignSurface(int n) case 4: view.Parent = tabPage4; break; + case 5: + view.Parent = tabPage5; + break; default: Console.WriteLine("Invalid selection"); break; diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Design/DesignerAttributeTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Design/DesignerAttributeTests.cs index 61cc88c1c91..a818c4065b4 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Design/DesignerAttributeTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Design/DesignerAttributeTests.cs @@ -39,9 +39,7 @@ public class DesignerAttributeTests "System.Windows.Forms.Design.PropertyGridDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Windows.Forms.Design.SaveFileDialogDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Windows.Forms.Design.StatusBarDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", - "System.Windows.Forms.Design.TabControlDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Windows.Forms.Design.TabPageDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", - "System.Windows.Forms.Design.TableLayoutPanelDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Windows.Forms.Design.ToolStripContainerDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Windows.Forms.Design.ToolStripContentPanelDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Windows.Forms.Design.ToolStripPanelDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", From 9c06949728507768e2d46e1887891bac219699e6 Mon Sep 17 00:00:00 2001 From: "Simon Zhao (Beyondsoft Corporation)" Date: Tue, 25 Jul 2023 17:04:23 +0800 Subject: [PATCH 014/231] Fix cloud building error --- .../Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs | 4 +++- .../IntegrationTests/DesignSurface/DemoConsole/MainForm.cs | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs index 8ffa34ee866..d8b7d57c64d 100644 --- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/Behavior/TableLayoutPanelBehavior.cs @@ -32,7 +32,9 @@ internal class TableLayoutPanelBehavior : Behavior #if DEBUG private static readonly TraceSwitch tlpResizeSwitch = new("TLPRESIZE", "Behavior service drag & drop messages"); #else - private static readonly TraceSwitch tlpResizeSwitch; +#pragma warning disable CS0649 + private static readonly TraceSwitch tlpResizeSwitch; +#pragma warning restore CS0649 #endif internal TableLayoutPanelBehavior(TableLayoutPanel panel, TableLayoutPanelDesigner designer, IServiceProvider serviceProvider) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs index 3e37e45e5c3..f3b2a8b43d8 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs @@ -232,8 +232,7 @@ private void CreateDesignSurface(int n) rootComponent.Text = "Root Component hosted by the DesignSurface N.5"; surface.CreateControl(new Size(400, 100), new Point(12, 21)); - - surface.CreateControl(new Size(290, 160), new Point(20, 220)); + surface.CreateControl(new Size(290, 160), new Point(20, 150)); } break; From 54c23935ce4ef6a5265377005e19c47bf9b37f8b Mon Sep 17 00:00:00 2001 From: "Simon Zhao (Beyondsoft Corporation)" Date: Tue, 25 Jul 2023 17:57:09 +0800 Subject: [PATCH 015/231] Add FlowPanelDesigner to System.Design.Facade project --- src/System.Design/src/System.Design.Forwards.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/System.Design/src/System.Design.Forwards.cs b/src/System.Design/src/System.Design.Forwards.cs index 2d973f8f33d..e90c02f663a 100644 --- a/src/System.Design/src/System.Design.Forwards.cs +++ b/src/System.Design/src/System.Design.Forwards.cs @@ -37,6 +37,7 @@ [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ComboBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.DateTimePickerDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.FormDocumentDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.FlowPanelDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.GroupBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.LabelDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListBoxDesigner))] From bb202c29e5bba861e40a3453e012413d71e78ba2 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 12:27:35 +0000 Subject: [PATCH 016/231] [main] Update dependencies from dotnet/runtime (#9562) [main] Update dependencies from dotnet/runtime --- eng/Version.Details.xml | 168 ++++++++++++++++++++-------------------- eng/Versions.props | 52 ++++++------- global.json | 2 +- 3 files changed, 111 insertions(+), 111 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 2f97bdecef4..0014d26181b 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,174 +7,174 @@ Note: if the Uri is a new place, you will need to add a subscription from that p --> - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb - + https://github.com/dotnet/runtime - 5b4bbda1c1c8a5cc4ced9facdacb4e531dfc8b3c + d1fc57ea18ee90aee8690697caed2b9f162409eb diff --git a/eng/Versions.props b/eng/Versions.props index 44b13333ff0..e6ba2630bff 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -13,34 +13,34 @@ - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 5.0.0-preview.7.20320.5 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 6.0.0 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 - 8.0.0-rc.1.23374.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.1 diff --git a/global.json b/global.json index 2d263b7874f..0bf4794120e 100644 --- a/global.json +++ b/global.json @@ -18,7 +18,7 @@ "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23371.1", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23371.1", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", - "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23374.1" + "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23375.1" }, "native-tools": { "cmake": "latest" From 08001329ab9895f886fd593fbda91a4432b28083 Mon Sep 17 00:00:00 2001 From: gpetrou <4172445+gpetrou@users.noreply.github.com> Date: Tue, 25 Jul 2023 20:31:07 +0300 Subject: [PATCH 017/231] Enable nullability in DataGridViewCellPaintingEventArgs (#9565) --- .../src/PublicAPI.Shipped.txt | 14 +- .../DataGridViewCellPaintingEventArgs.cs | 141 ++++++++++-------- 2 files changed, 82 insertions(+), 73 deletions(-) diff --git a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt index 4ed7e980d2c..4beda8814bc 100644 --- a/src/System.Windows.Forms/src/PublicAPI.Shipped.txt +++ b/src/System.Windows.Forms/src/PublicAPI.Shipped.txt @@ -441,13 +441,13 @@ System.Windows.Forms.AxHost.SetAboutBoxDelegate(System.Windows.Forms.AxHost.Abou ~System.Windows.Forms.DataGridViewCellCollection.this[int index].set -> void ~System.Windows.Forms.DataGridViewCellCollection.this[string columnName].get -> System.Windows.Forms.DataGridViewCell ~System.Windows.Forms.DataGridViewCellCollection.this[string columnName].set -> void -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.AdvancedBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.CellStyle.get -> System.Windows.Forms.DataGridViewCellStyle -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.DataGridViewCellPaintingEventArgs(System.Windows.Forms.DataGridView dataGridView, System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, int columnIndex, System.Windows.Forms.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, System.Windows.Forms.DataGridViewCellStyle cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle, System.Windows.Forms.DataGridViewPaintParts paintParts) -> void -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.ErrorText.get -> string -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.FormattedValue.get -> object -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.Graphics.get -> System.Drawing.Graphics -~System.Windows.Forms.DataGridViewCellPaintingEventArgs.Value.get -> object +System.Windows.Forms.DataGridViewCellPaintingEventArgs.AdvancedBorderStyle.get -> System.Windows.Forms.DataGridViewAdvancedBorderStyle? +System.Windows.Forms.DataGridViewCellPaintingEventArgs.CellStyle.get -> System.Windows.Forms.DataGridViewCellStyle? +System.Windows.Forms.DataGridViewCellPaintingEventArgs.DataGridViewCellPaintingEventArgs(System.Windows.Forms.DataGridView! dataGridView, System.Drawing.Graphics! graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, int columnIndex, System.Windows.Forms.DataGridViewElementStates cellState, object? value, object? formattedValue, string? errorText, System.Windows.Forms.DataGridViewCellStyle! cellStyle, System.Windows.Forms.DataGridViewAdvancedBorderStyle? advancedBorderStyle, System.Windows.Forms.DataGridViewPaintParts paintParts) -> void +System.Windows.Forms.DataGridViewCellPaintingEventArgs.ErrorText.get -> string? +System.Windows.Forms.DataGridViewCellPaintingEventArgs.FormattedValue.get -> object? +System.Windows.Forms.DataGridViewCellPaintingEventArgs.Graphics.get -> System.Drawing.Graphics? +System.Windows.Forms.DataGridViewCellPaintingEventArgs.Value.get -> object? ~System.Windows.Forms.DataGridViewCellStyle.DataGridViewCellStyle(System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle) -> void ~System.Windows.Forms.DataGridViewCellStyle.DataSourceNullValue.get -> object ~System.Windows.Forms.DataGridViewCellStyle.DataSourceNullValue.set -> void diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellPaintingEventArgs.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellPaintingEventArgs.cs index c5556001cde..e6cbf888754 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellPaintingEventArgs.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewCellPaintingEventArgs.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable disable - using System.ComponentModel; using System.Drawing; @@ -13,19 +11,20 @@ public class DataGridViewCellPaintingEventArgs : HandledEventArgs { private readonly DataGridView _dataGridView; - public DataGridViewCellPaintingEventArgs(DataGridView dataGridView, - Graphics graphics, - Rectangle clipBounds, - Rectangle cellBounds, - int rowIndex, - int columnIndex, - DataGridViewElementStates cellState, - object value, - object formattedValue, - string errorText, - DataGridViewCellStyle cellStyle, - DataGridViewAdvancedBorderStyle advancedBorderStyle, - DataGridViewPaintParts paintParts) + public DataGridViewCellPaintingEventArgs( + DataGridView dataGridView, + Graphics graphics, + Rectangle clipBounds, + Rectangle cellBounds, + int rowIndex, + int columnIndex, + DataGridViewElementStates cellState, + object? value, + object? formattedValue, + string? errorText, + DataGridViewCellStyle cellStyle, + DataGridViewAdvancedBorderStyle? advancedBorderStyle, + DataGridViewPaintParts paintParts) { if ((paintParts & ~DataGridViewPaintParts.All) != 0) { @@ -53,9 +52,9 @@ internal DataGridViewCellPaintingEventArgs(DataGridView dataGridView) _dataGridView = dataGridView; } - public Graphics Graphics { get; private set; } + public Graphics? Graphics { get; private set; } - public DataGridViewAdvancedBorderStyle AdvancedBorderStyle { get; private set; } + public DataGridViewAdvancedBorderStyle? AdvancedBorderStyle { get; private set; } public Rectangle CellBounds { get; private set; } @@ -67,13 +66,13 @@ internal DataGridViewCellPaintingEventArgs(DataGridView dataGridView) public DataGridViewElementStates State { get; private set; } - public object Value { get; private set; } + public object? Value { get; private set; } - public object FormattedValue { get; private set; } + public object? FormattedValue { get; private set; } - public string ErrorText { get; private set; } + public string? ErrorText { get; private set; } - public DataGridViewCellStyle CellStyle { get; private set; } + public DataGridViewCellStyle? CellStyle { get; private set; } public DataGridViewPaintParts PaintParts { get; private set; } @@ -89,17 +88,20 @@ public void Paint(Rectangle clipBounds, DataGridViewPaintParts paintParts) throw new InvalidOperationException(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange); } - _dataGridView.GetCellInternal(ColumnIndex, RowIndex).PaintInternal(Graphics, - clipBounds, - CellBounds, - RowIndex, - State, - Value, - FormattedValue, - ErrorText, - CellStyle, - AdvancedBorderStyle, - paintParts); + _dataGridView + .GetCellInternal(ColumnIndex, RowIndex) + .PaintInternal( + Graphics, + clipBounds, + CellBounds, + RowIndex, + State, + Value, + FormattedValue, + ErrorText, + CellStyle, + AdvancedBorderStyle, + paintParts); } public void PaintBackground(Rectangle clipBounds, bool cellsPaintSelectionBackground) @@ -120,17 +122,20 @@ public void PaintBackground(Rectangle clipBounds, bool cellsPaintSelectionBackgr paintParts |= DataGridViewPaintParts.SelectionBackground; } - _dataGridView.GetCellInternal(ColumnIndex, RowIndex).PaintInternal(Graphics, - clipBounds, - CellBounds, - RowIndex, - State, - Value, - FormattedValue, - ErrorText, - CellStyle, - AdvancedBorderStyle, - paintParts); + _dataGridView + .GetCellInternal(ColumnIndex, RowIndex) + .PaintInternal( + Graphics, + clipBounds, + CellBounds, + RowIndex, + State, + Value, + FormattedValue, + ErrorText, + CellStyle, + AdvancedBorderStyle, + paintParts); } public void PaintContent(Rectangle clipBounds) @@ -145,31 +150,35 @@ public void PaintContent(Rectangle clipBounds) throw new InvalidOperationException(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange); } - _dataGridView.GetCellInternal(ColumnIndex, RowIndex).PaintInternal(Graphics, - clipBounds, - CellBounds, - RowIndex, - State, - Value, - FormattedValue, - ErrorText, - CellStyle, - AdvancedBorderStyle, - DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.ErrorIcon); + _dataGridView + .GetCellInternal(ColumnIndex, RowIndex) + .PaintInternal( + Graphics, + clipBounds, + CellBounds, + RowIndex, + State, + Value, + FormattedValue, + ErrorText, + CellStyle, + AdvancedBorderStyle, + DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.ErrorIcon); } - internal void SetProperties(Graphics graphics, - Rectangle clipBounds, - Rectangle cellBounds, - int rowIndex, - int columnIndex, - DataGridViewElementStates cellState, - object value, - object formattedValue, - string errorText, - DataGridViewCellStyle cellStyle, - DataGridViewAdvancedBorderStyle advancedBorderStyle, - DataGridViewPaintParts paintParts) + internal void SetProperties( + Graphics graphics, + Rectangle clipBounds, + Rectangle cellBounds, + int rowIndex, + int columnIndex, + DataGridViewElementStates cellState, + object? value, + object? formattedValue, + string? errorText, + DataGridViewCellStyle cellStyle, + DataGridViewAdvancedBorderStyle advancedBorderStyle, + DataGridViewPaintParts paintParts) { Debug.Assert(graphics is not null); From 9e6259ea86ec823f2d73f7d844543266bda2ecb1 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Tue, 25 Jul 2023 16:29:05 -0700 Subject: [PATCH 018/231] Add feature/9.0 branch to CI (#9567) --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8ba94c0ec10..9091f016da3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,6 +34,7 @@ pr: - internal/release/* - internal/experimental/* - feature/win32 + - feature/9.0 paths: include: - '*' From 32d5b299b75698f0640a88d814121d4cdd26de10 Mon Sep 17 00:00:00 2001 From: gpetrou <4172445+gpetrou@users.noreply.github.com> Date: Wed, 26 Jul 2023 03:04:42 +0300 Subject: [PATCH 019/231] Enable nullability in BindToObject (#9554) * Move BindToObject to a separate file * Enable nullability in BindToObject * Use pattern matching * Make lManager nullable * Make value nullable * Use pattern matching and remove text variable --- .../Windows/Forms/Binding.BindToObject.cs | 246 ++++++++++++++++++ .../src/System/Windows/Forms/Binding.cs | 239 +---------------- .../src/System/Windows/Forms/ErrorProvider.cs | 4 +- 3 files changed, 249 insertions(+), 240 deletions(-) create mode 100644 src/System.Windows.Forms/src/System/Windows/Forms/Binding.BindToObject.cs diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Binding.BindToObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.BindToObject.cs new file mode 100644 index 00000000000..cd7c06df0e6 --- /dev/null +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.BindToObject.cs @@ -0,0 +1,246 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; + +namespace System.Windows.Forms; + +public partial class Binding +{ + private class BindToObject + { + private BindingManagerBase? _bindingManager; + private readonly Binding _owner; + private bool _dataSourceInitialized; + private bool _waitingOnDataSource; + + private void PropValueChanged(object? sender, EventArgs e) + { + _bindingManager?.OnCurrentChanged(EventArgs.Empty); + } + + private bool IsDataSourceInitialized + { + get + { + Debug.Assert(_owner.DataSource is not null, "how can we determine if DataSource is initialized or not if we have no data source?"); + if (_dataSourceInitialized) + { + return true; + } + + if (_owner.DataSource is not ISupportInitializeNotification ds || ds.IsInitialized) + { + _dataSourceInitialized = true; + return true; + } + + // We have an ISupportInitializeNotification which was not initialized yet. + // We already hooked up the Initialized event and the data source is not initialized yet. + if (_waitingOnDataSource) + { + return false; + } + + // Hook up the Initialized event. + ds.Initialized += new EventHandler(DataSource_Initialized); + _waitingOnDataSource = true; + return false; + } + } + + internal BindToObject(Binding owner) + { + Debug.Assert(owner is not null); + _owner = owner; + CheckBinding(); + } + + private void DataSource_Initialized(object? sender, EventArgs e) + { + Debug.Assert(sender == _owner.DataSource, "data source should not change"); + Debug.Assert(_owner.DataSource is ISupportInitializeNotification, "data source should not change on the BindToObject"); + Debug.Assert(_waitingOnDataSource); + + // Unhook the Initialized event. + if (_owner.DataSource is ISupportInitializeNotification ds) + { + ds.Initialized -= new EventHandler(DataSource_Initialized); + } + + // The wait is over: DataSource is initialized. + _waitingOnDataSource = false; + _dataSourceInitialized = true; + + // Rebind. + CheckBinding(); + } + + internal void SetBindingManagerBase(BindingManagerBase? lManager) + { + if (_bindingManager == lManager) + { + return; + } + + // remove notification from the backEnd + if (_bindingManager is not null && + FieldInfo is not null && + _bindingManager.IsBinding && + _bindingManager is not CurrencyManager) + { + FieldInfo.RemoveValueChanged(_bindingManager.Current!, new EventHandler(PropValueChanged)); + FieldInfo = null; + } + + _bindingManager = lManager; + CheckBinding(); + } + + internal string DataErrorText { get; private set; } = string.Empty; + + /// + /// Returns any data error info on the data source for the bound data field + /// in the current row + /// + private string GetErrorText(object? value) + { + if (value is not IDataErrorInfo errorInfo) + { + return string.Empty; + } + + // Get the row error if there is no DataMember + if (FieldInfo is null) + { + return errorInfo.Error ?? string.Empty; + } + + // Get the column error if there is a DataMember. + // The DataTable uses its own Locale to lookup column names . + // So passing the DataMember from the BindingField could cause problems. + // Pass the name from the PropertyDescriptor that the DataTable gave us. + // (If there is no fieldInfo, data binding would have failed already ) + return errorInfo[FieldInfo.Name] ?? string.Empty; + } + + internal object? GetValue() + { + object? obj = _bindingManager?.Current; + + // Update IDataErrorInfo text: it's ok to get this now because we're going to need + // this as part of the BindingCompleteEventArgs anyway. + DataErrorText = GetErrorText(obj); + + if (FieldInfo is not null) + { + obj = FieldInfo.GetValue(obj); + } + + return obj; + } + + internal Type? BindToType + { + get + { + if (_owner.BindingMemberInfo.BindingField.Length == 0) + { + // if we are bound to a list w/o any properties, then + // take the type from the BindingManager + Type? type = _bindingManager?.BindType; + if (typeof(Array).IsAssignableFrom(type)) + { + type = type.GetElementType(); + } + + return type; + } + + return FieldInfo?.PropertyType; + } + } + + internal void SetValue(object? value) + { + object? obj = null; + + if (FieldInfo is not null) + { + obj = _bindingManager?.Current; + if (obj is IEditableObject editableObject) + { + editableObject.BeginEdit(); + } + + if (!FieldInfo.IsReadOnly) + { + FieldInfo.SetValue(obj, value); + } + } + else + { + if (_bindingManager is CurrencyManager cm) + { + cm[cm.Position] = value; + obj = value; + } + } + + // Update IDataErrorInfo text. + DataErrorText = GetErrorText(obj); + } + + internal PropertyDescriptor? FieldInfo { get; private set; } + + internal void CheckBinding() + { + // At design time, don't check anything. + if (_owner.BindableComponent is not null && _owner.ControlAtDesignTime()) + { + return; + } + + // Remove propertyChangedNotification when this binding is deleted + if (_bindingManager is not null && + FieldInfo is not null && + _bindingManager.IsBinding && + _bindingManager is not CurrencyManager) + { + FieldInfo.RemoveValueChanged(_bindingManager.Current!, new EventHandler(PropValueChanged)); + } + + if (_bindingManager is not null && + _owner.BindableComponent is not null && + _owner.ComponentCreated && + IsDataSourceInitialized) + { + string dataField = _owner.BindingMemberInfo.BindingField; + + FieldInfo = _bindingManager.GetItemProperties().Find(dataField, true); + if (_bindingManager.DataSource is not null && FieldInfo is null && dataField.Length > 0) + { + throw new ArgumentException(string.Format(SR.ListBindingBindField, dataField), "dataMember"); + } + + // Do not add propertyChange notification if the fieldInfo is null + // + // We add an event handler to the dataSource in the BindingManagerBase because + // if the binding is of the form (Control, ControlProperty, DataSource, Property1.Property2.Property3) + // then we want to get notification from Current.Property1.Property2 and not from DataSource + // when we get the backEnd notification we push the new value into the Control's property + if (FieldInfo is not null && + _bindingManager.IsBinding && + _bindingManager is not CurrencyManager) + { + FieldInfo.AddValueChanged(_bindingManager.Current!, new EventHandler(PropValueChanged)); + } + } + else + { + FieldInfo = null; + } + } + } +} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs index 98697493021..d64f4e49c30 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Binding.cs @@ -13,7 +13,7 @@ namespace System.Windows.Forms; /// Represents a simple binding of a value in a list and the property of a control. /// [TypeConverter(typeof(ListBindingConverter))] -public class Binding +public partial class Binding { private BindingManagerBase _bindingManagerBase; @@ -1091,241 +1091,4 @@ internal void UpdateIsBinding() } } } - - private class BindToObject - { - private BindingManagerBase _bindingManager; - private readonly Binding _owner; - private bool _dataSourceInitialized; - private bool _waitingOnDataSource; - - private void PropValueChanged(object sender, EventArgs e) - { - _bindingManager?.OnCurrentChanged(EventArgs.Empty); - } - - private bool IsDataSourceInitialized - { - get - { - Debug.Assert(_owner.DataSource is not null, "how can we determine if DataSource is initialized or not if we have no data source?"); - if (_dataSourceInitialized) - { - return true; - } - - if (!(_owner.DataSource is ISupportInitializeNotification ds) || ds.IsInitialized) - { - _dataSourceInitialized = true; - return true; - } - - // We have an ISupportInitializeNotification which was not initialized yet. - // We already hooked up the Initialized event and the data source is not initialized yet. - if (_waitingOnDataSource) - { - return false; - } - - // Hook up the Initialized event. - ds.Initialized += new EventHandler(DataSource_Initialized); - _waitingOnDataSource = true; - return false; - } - } - - internal BindToObject(Binding owner) - { - Debug.Assert(owner is not null); - _owner = owner; - CheckBinding(); - } - - private void DataSource_Initialized(object sender, EventArgs e) - { - Debug.Assert(sender == _owner.DataSource, "data source should not change"); - Debug.Assert(_owner.DataSource is ISupportInitializeNotification, "data source should not change on the BindToObject"); - Debug.Assert(_waitingOnDataSource); - - // Unhook the Initialized event. - if (_owner.DataSource is ISupportInitializeNotification ds) - { - ds.Initialized -= new EventHandler(DataSource_Initialized); - } - - // The wait is over: DataSource is initialized. - _waitingOnDataSource = false; - _dataSourceInitialized = true; - - // Rebind. - CheckBinding(); - } - - internal void SetBindingManagerBase(BindingManagerBase lManager) - { - if (_bindingManager == lManager) - { - return; - } - - // remove notification from the backEnd - if (_bindingManager is not null && FieldInfo is not null && _bindingManager.IsBinding && !(_bindingManager is CurrencyManager)) - { - FieldInfo.RemoveValueChanged(_bindingManager.Current, new EventHandler(PropValueChanged)); - FieldInfo = null; - } - - _bindingManager = lManager; - CheckBinding(); - } - - internal string DataErrorText { get; private set; } = string.Empty; - - /// - /// Returns any data error info on the data source for the bound data field - /// in the current row - /// - private string GetErrorText(object value) - { - string text = string.Empty; - - if (value is IDataErrorInfo errorInfo) - { - // Get the row error if there is no DataMember - if (FieldInfo is null) - { - text = errorInfo.Error; - } - - // Get the column error if there is a DataMember. - // The DataTable uses its own Locale to lookup column names . - // So passing the DataMember from the BindingField could cause problems. - // Pass the name from the PropertyDescriptor that the DataTable gave us. - // (If there is no fieldInfo, data binding would have failed already ) - else - { - text = errorInfo[FieldInfo.Name]; - } - } - - return text ?? string.Empty; - } - - internal object GetValue() - { - object obj = _bindingManager.Current; - - // Update IDataErrorInfo text: it's ok to get this now because we're going to need - // this as part of the BindingCompleteEventArgs anyway. - DataErrorText = GetErrorText(obj); - - if (FieldInfo is not null) - { - obj = FieldInfo.GetValue(obj); - } - - return obj; - } - - internal Type BindToType - { - get - { - if (_owner.BindingMemberInfo.BindingField.Length == 0) - { - // if we are bound to a list w/o any properties, then - // take the type from the BindingManager - Type type = _bindingManager.BindType; - if (typeof(Array).IsAssignableFrom(type)) - { - type = type.GetElementType(); - } - - return type; - } - - return FieldInfo?.PropertyType; - } - } - - internal void SetValue(object value) - { - object obj = null; - - if (FieldInfo is not null) - { - obj = _bindingManager.Current; - if (obj is IEditableObject editableObject) - { - editableObject.BeginEdit(); - } - - if (!FieldInfo.IsReadOnly) - { - FieldInfo.SetValue(obj, value); - } - } - else - { - if (_bindingManager is CurrencyManager cm) - { - cm[cm.Position] = value; - obj = value; - } - } - - // Update IDataErrorInfo text. - DataErrorText = GetErrorText(obj); - } - - internal PropertyDescriptor FieldInfo { get; private set; } - - internal void CheckBinding() - { - // At design time, don't check anything. - if (_owner.BindableComponent is not null && _owner.ControlAtDesignTime()) - { - return; - } - - // Remove propertyChangedNotification when this binding is deleted - if (_bindingManager is not null && - FieldInfo is not null && - _bindingManager.IsBinding && - !(_bindingManager is CurrencyManager)) - { - FieldInfo.RemoveValueChanged(_bindingManager.Current, new EventHandler(PropValueChanged)); - } - - if (_bindingManager is not null && - _owner.BindableComponent is not null && - _owner.ComponentCreated && - IsDataSourceInitialized) - { - string dataField = _owner.BindingMemberInfo.BindingField; - - FieldInfo = _bindingManager.GetItemProperties().Find(dataField, true); - if (_bindingManager.DataSource is not null && FieldInfo is null && dataField.Length > 0) - { - throw new ArgumentException(string.Format(SR.ListBindingBindField, dataField), "dataMember"); - } - - // Do not add propertyChange notification if the fieldInfo is null - // - // We add an event handler to the dataSource in the BindingManagerBase because - // if the binding is of the form (Control, ControlProperty, DataSource, Property1.Property2.Property3) - // then we want to get notification from Current.Property1.Property2 and not from DataSource - // when we get the backEnd notification we push the new value into the Control's property - if (FieldInfo is not null && _bindingManager.IsBinding && - !(_bindingManager is CurrencyManager)) - { - FieldInfo.AddValueChanged(_bindingManager.Current, new EventHandler(PropValueChanged)); - } - } - else - { - FieldInfo = null; - } - } - } } diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs index 035d96ee532..7086dc327cf 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider.cs @@ -460,7 +460,7 @@ private void ErrorManager_CurrentChanged(object? sender, EventArgs e) } object? value = _errorManager.Current; - if (value is not IDataErrorInfo) + if (value is not IDataErrorInfo dataErrorInfo) { return; } @@ -487,7 +487,7 @@ private void ErrorManager_CurrentChanged(object? sender, EventArgs e) } Binding dataBinding = errBindings[j]; - string error = ((IDataErrorInfo)value)[dataBinding.BindingMemberInfo.BindingField]; + string error = dataErrorInfo[dataBinding.BindingMemberInfo.BindingField]; error ??= string.Empty; From 274e7a0f0f2dd6d51a8153594408f4aa99e57d5f Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 26 Jul 2023 12:27:30 +0000 Subject: [PATCH 020/231] [main] Update dependencies from dotnet/runtime (#9571) [main] Update dependencies from dotnet/runtime --- eng/Version.Details.xml | 168 ++++++++++++++++++++-------------------- eng/Versions.props | 52 ++++++------- global.json | 2 +- 3 files changed, 111 insertions(+), 111 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 0014d26181b..3a83aa14170 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -7,174 +7,174 @@ Note: if the Uri is a new place, you will need to add a subscription from that p --> - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 - + https://github.com/dotnet/runtime - d1fc57ea18ee90aee8690697caed2b9f162409eb + d389ab955dbb65547643fa1aed52669b02c04294 diff --git a/eng/Versions.props b/eng/Versions.props index e6ba2630bff..45a8463e63d 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -13,34 +13,34 @@ - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 5.0.0-preview.7.20320.5 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 6.0.0 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 - 8.0.0-rc.1.23375.1 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 + 8.0.0-rc.1.23375.8 diff --git a/global.json b/global.json index 0bf4794120e..05a23357966 100644 --- a/global.json +++ b/global.json @@ -18,7 +18,7 @@ "Microsoft.DotNet.CMake.Sdk": "8.0.0-beta.23371.1", "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23371.1", "FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", - "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23375.1" + "Microsoft.NET.Sdk.IL": "8.0.0-rc.1.23375.8" }, "native-tools": { "cmake": "latest" From 5b659e9f861aaf2b87c775f8700aa79c0a7fa52a Mon Sep 17 00:00:00 2001 From: Leaf Shi <132890443+LeafShi1@users.noreply.github.com> Date: Wed, 26 Jul 2023 10:06:03 -0700 Subject: [PATCH 021/231] Port MonthCalendarDesigner to runtime (#9536) * Port MonthCalendarDesigner to runtime * Delete unnecessary namespace * Delete redundant assertions and redundant judgment conditions * Update MonthCalendarDesigner.cs to use file-scoped namespaces --- .../src/System.Design.Forwards.cs | 1 + .../Forms/Design/MonthCalendarDesigner.cs | 33 +++++++++++++++++++ .../DesignSurface/DemoConsole/MainForm.cs | 6 ++-- .../Forms/Design/DesignerAttributeTests.cs | 1 - 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MonthCalendarDesigner.cs diff --git a/src/System.Design/src/System.Design.Forwards.cs b/src/System.Design/src/System.Design.Forwards.cs index 736ef9f0a65..203ae2a37e0 100644 --- a/src/System.Design/src/System.Design.Forwards.cs +++ b/src/System.Design/src/System.Design.Forwards.cs @@ -42,6 +42,7 @@ [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListViewDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.MaskedTextBoxDesigner))] +[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.MonthCalendarDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PanelDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PictureBoxDesigner))] [assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.RadioButtonDesigner))] diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MonthCalendarDesigner.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MonthCalendarDesigner.cs new file mode 100644 index 00000000000..216d77f7590 --- /dev/null +++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/MonthCalendarDesigner.cs @@ -0,0 +1,33 @@ +namespace System.Windows.Forms.Design; + +internal class MonthCalendarDesigner : ControlDesigner +{ + public MonthCalendarDesigner() + { + AutoResizeHandles = true; + } + + /// + /// Retrieves a set of rules concerning the movement capabilities of a component. + /// This should be one or more flags from the SelectionRules class. If no designer + /// provides rules for a component, the component will not get any UI services. + /// + public override SelectionRules SelectionRules + { + get + { + SelectionRules rules = base.SelectionRules; + + if (Control.Parent is null || !Control.Parent.IsMirrored) + { + rules &= ~(SelectionRules.TopSizeable | SelectionRules.LeftSizeable); + } + else + { + rules &= ~(SelectionRules.TopSizeable | SelectionRules.RightSizeable); + } + + return rules; + } + } +} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs index 48574a235ee..6890662424e 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/DesignSurface/DemoConsole/MainForm.cs @@ -203,13 +203,13 @@ private void CreateDesignSurface(int n) break; case 4: { - rootComponent = surface.CreateRootComponent(new Size(320, 200)); + rootComponent = surface.CreateRootComponent(new Size(800, 600)); rootComponent.BackColor = Color.Orange; rootComponent.Text = "Root Component hosted by the DesignSurface N.4"; //- step.1 //- step.3 //- create some Controls at DesignTime Button b1 = surface.CreateControl