Skip to content

Modernize C# code snippets (more System.ComponentModel) - #13019

Merged
gewarren merged 4 commits into
dotnet:mainfrom
gewarren:modernize-system-componentmodel-more
Aug 24, 2026
Merged

Modernize C# code snippets (more System.ComponentModel)#13019
gewarren merged 4 commits into
dotnet:mainfrom
gewarren:modernize-system-componentmodel-more

Conversation

@gewarren

@gewarren gewarren commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Contributes to #12713.


Internal previews

Toggle expand/collapse
File Preview link
snippets/csharp/System.ComponentModel.Composition.Hosting/CompositionContainer/Compose/program.cs Preview published page
snippets/csharp/System.ComponentModel.Composition.Hosting/CompositionContainer/Overview/program.cs Preview published page
snippets/csharp/System.ComponentModel.Composition.Hosting/DirectoryCatalog/classlibrary1/class1.cs Preview published page
snippets/csharp/System.ComponentModel.Composition.Hosting/DirectoryCatalog/consoleapplication7/program.cs Preview published page
snippets/csharp/System.ComponentModel.Composition/ExportAttribute/program.cs Preview published page
snippets/csharp/System.ComponentModel.Design.Serialization/CodeDomSerializer/Overview/idesignerserializationmanagersample.cs Preview published page
snippets/csharp/System.ComponentModel.Design.Serialization/CodeDomSerializerException/Overview/source.cs Preview published page
snippets/csharp/System.ComponentModel.Design.Serialization/ContextStack/Overview/class1.cs Preview published page
snippets/csharp/System.ComponentModel.Design.Serialization/DesignerSerializerAttribute/Overview/source.cs Preview published page
snippets/csharp/System.ComponentModel.Design.Serialization/INameCreationService/Overview/class1.cs Preview published page
snippets/csharp/System.ComponentModel.Design.Serialization/ResolveNameEventArgs/Overview/class1.cs Preview published page
snippets/csharp/System.ComponentModel.Design.Serialization/ResolveNameEventHandler/Overview/form1.cs Preview published page
snippets/csharp/System.ComponentModel.Design/ActiveDesignerEventArgs/Overview/class1.cs Preview published page
snippets/csharp/System.ComponentModel.Design/ActiveDesignerEventHandler/Overview/activedesignereventhandlerexample.cs Preview published page
snippets/csharp/System.ComponentModel.Design/ArrayEditor/Overview/class1.cs Preview published page
snippets/csharp/System.ComponentModel.Design/ComponentChangedEventArgs/Overview/componentchangedeventargsexample.cs Preview published page
snippets/csharp/System.ComponentModel.Design/ComponentChangedEventHandler/Overview/componentchangedeventhandlerexample.cs Preview published page
snippets/csharp/System.ComponentModel.Design/ComponentChangingEventHandler/Overview/componentchangingeventhandlerexample.cs Preview published page
snippets/csharp/System.ComponentModel.Design/ComponentDesigner/Overview/examplecomponent.cs Preview published page
snippets/csharp/System.ComponentModel.Design/ComponentEventHandler/Overview/componenteventhandlerexample.cs Preview published page
snippets/csharp/System.ComponentModel.Design/ComponentRenameEventHandler/Overview/componentrenameeventhandlerexample.cs Preview published page
snippets/csharp/System.ComponentModel.Design/DesignerActionHeaderItem/Overview/designeractions.cs Preview published page
snippets/csharp/System.ComponentModel.Design/DesignerCollection/Overview/examplecomponent.cs Preview published page
snippets/csharp/System.ComponentModel.Design/DesignerEventHandler/Overview/designereventhandlerexample.cs Preview published page
snippets/csharp/System.ComponentModel.Design/DesignerTransactionCloseEventHandler/Overview/designertransactioncloseeventhandlerexample.cs Preview published page
snippets/csharp/System.ComponentModel.Design/DesignerVerb/Overview/component1.cs Preview published page
snippets/csharp/System.ComponentModel.Design/DesignerVerbCollection/Overview/class1.cs Preview published page
snippets/csharp/System.ComponentModel.Design/IDesigner/Overview/testcontrol.cs Preview published page
snippets/csharp/System.ComponentModel.Design/IEventBindingService/Overview/source.cs Preview published page
snippets/csharp/System.ComponentModel.Design/IExtenderListService/Overview/extenderlistserviceexample.cs Preview published page

Note

This table shows the first 30 preview links (sorted alphabetically by file path) found in the OPS build report. For the full list, select OpenPublishing.Build Details within checks.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Modernizes System.ComponentModel C# snippets while preserving their documented APIs and adds build coverage for previously unprojected samples.

Changes:

  • Applies modern C# syntax, formatting, naming, and string interpolation.
  • Cleans up comments, imports, and redundant code.
  • Adds two .NET 10 Windows Forms snippet projects.

Reviewed changes

Copilot reviewed 68 out of 71 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
snippets/csharp/System.ComponentModel/Win32Exception/Overview/win32exception.cs Simplifies value output.
snippets/csharp/System.ComponentModel/TypeDescriptor/GetProperties/Form1.cs Uses string interpolation.
snippets/csharp/System.ComponentModel/TypeConverterAttribute/Overview/source.cs Modernizes output formatting.
snippets/csharp/System.ComponentModel/TypeConverter/Overview/source.cs Reformats enum declaration.
snippets/csharp/System.ComponentModel/ToolboxItemFilterAttribute/Overview/samplecontrol.cs Modernizes construction and formatting.
snippets/csharp/System.ComponentModel/ToolboxItemAttribute/Overview/Form1.cs Modernizes Windows Forms initialization.
snippets/csharp/System.ComponentModel/RefreshEventHandler/Overview/refreshevent.cs Cleans comments and output.
snippets/csharp/System.ComponentModel/ReadOnlyAttribute/Overview/source.cs Corrects indentation.
snippets/csharp/System.ComponentModel/ReadOnlyAttribute/IsReadOnly/source.cs Corrects indentation.
snippets/csharp/System.ComponentModel/ProvidePropertyAttribute/Overview/source.cs Cleans comment formatting.
snippets/csharp/System.ComponentModel/PropertyTabAttribute/Overview/class1.cs Reformats property construction.
snippets/csharp/System.ComponentModel/PropertyDescriptorCollection/Overview/source.cs Corrects comment grammar.
snippets/csharp/System.ComponentModel/PropertyDescriptorCollection/Item/source1.cs Reformats and disambiguates sample type.
snippets/csharp/System.ComponentModel/PropertyDescriptorCollection/Item/source.cs Reformats indexer sample.
snippets/csharp/System.ComponentModel/PropertyDescriptorCollection/Item/Project.csproj Adds .NET 10 project.
snippets/csharp/System.ComponentModel/PropertyDescriptorCollection/Item/Program.cs Adds project entry point.
snippets/csharp/System.ComponentModel/PropertyDescriptorCollection/GetEnumerator/source.cs Simplifies enumeration output.
snippets/csharp/System.ComponentModel/PropertyDescriptorCollection/Find/source.cs Modernizes formatting and grammar.
snippets/csharp/System.ComponentModel/PropertyDescriptorCollection/Count/source.cs Modernizes count output.
snippets/csharp/System.ComponentModel/PropertyDescriptor/Overview/SerializeReadOnlyPropertyDescriptor.cs Cleans comments.
snippets/csharp/System.ComponentModel/PropertyDescriptor/Overview/propertydescriptor.cs Modernizes descriptor output.
snippets/csharp/System.ComponentModel/LicenseProviderAttribute/Overview/source.cs Uses string interpolation.
snippets/csharp/System.ComponentModel/ISupportInitialize/Overview/form1.cs Modernizes initialization and output.
snippets/csharp/System.ComponentModel/IListSource/Overview/Employee.cs Modernizes fields and constructors.
snippets/csharp/System.ComponentModel/IEditableCollectionViewAddNewItem/Overview/data.cs Modernizes formatting and defaults.
snippets/csharp/System.ComponentModel/IEditableCollectionView/Overview/Window1.xaml.cs Modernizes formatting and collection syntax.
snippets/csharp/System.ComponentModel/EventDescriptorCollection/GetEnumerator/source.cs Simplifies enumerator handling.
snippets/csharp/System.ComponentModel/EventDescriptorCollection/Count/source.cs Modernizes count output.
snippets/csharp/System.ComponentModel/DoWorkEventArgs/Overview/Form1.cs Uses string interpolation.
snippets/csharp/System.ComponentModel/DesignOnlyAttribute/Overview/source.cs Modernizes output formatting.
snippets/csharp/System.ComponentModel/DefaultValueAttribute/Overview/source.cs Modernizes output formatting.
snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/Project.csproj Adds .NET 10 project.
snippets/csharp/System.ComponentModel/BindingListT/Overview/Form1.cs Modernizes construction and handlers.
snippets/csharp/System.ComponentModel/AttributeCollection/GetEnumerator/source.cs Simplifies enumeration logic.
snippets/csharp/System.ComponentModel/AttributeCollection/Count/source.cs Simplifies collection initialization.
snippets/csharp/System.ComponentModel/AmbientValueAttribute/Overview/form1.cs Uses string interpolation.
snippets/csharp/System.ComponentModel/AmbientValueAttribute/Overview/attributesdemocontrol.cs Sorts imports and modernizes formatting.
snippets/csharp/System.ComponentModel.Design/ServiceCreatorCallback/Overview/source.cs Reformats callback sample.
snippets/csharp/System.ComponentModel.Design/IRootDesigner/Overview/class1.cs Modernizes fields and collections.
snippets/csharp/System.ComponentModel.Design/IResourceService/Overview/source.cs Modernizes resource designer syntax.
snippets/csharp/System.ComponentModel.Design/IExtenderListService/Overview/extenderlistserviceexample.cs Modernizes loops and initialization.
snippets/csharp/System.ComponentModel.Design/IEventBindingService/Overview/source.cs Modernizes event-binding logic.
snippets/csharp/System.ComponentModel.Design/IDesigner/Overview/testcontrol.cs Simplifies designer implementation.
snippets/csharp/System.ComponentModel.Design/DesignerVerbCollection/Overview/class1.cs Modernizes collection operations.
snippets/csharp/System.ComponentModel.Design/DesignerVerb/Overview/component1.cs Modernizes verb initialization.
snippets/csharp/System.ComponentModel.Design/DesignerTransactionCloseEventHandler/Overview/designertransactioncloseeventhandlerexample.cs Adds braces and cleans handlers.
snippets/csharp/System.ComponentModel.Design/DesignerEventHandler/Overview/designereventhandlerexample.cs Modernizes handler output.
snippets/csharp/System.ComponentModel.Design/DesignerCollection/Overview/examplecomponent.cs Reformats collection iteration.
snippets/csharp/System.ComponentModel.Design/DesignerActionHeaderItem/Overview/designeractions.cs Simplifies properties and initialization.
snippets/csharp/System.ComponentModel.Design/ComponentRenameEventHandler/Overview/componentrenameeventhandlerexample.cs Modernizes event output.
snippets/csharp/System.ComponentModel.Design/ComponentEventHandler/Overview/componenteventhandlerexample.cs Modernizes event handling.
snippets/csharp/System.ComponentModel.Design/ComponentDesigner/Overview/examplecomponent.cs Simplifies designer API usage.
snippets/csharp/System.ComponentModel.Design/ComponentChangingEventHandler/Overview/componentchangingeventhandlerexample.cs Modernizes event output.
snippets/csharp/System.ComponentModel.Design/ComponentChangedEventHandler/Overview/componentchangedeventhandlerexample.cs Modernizes event output.
snippets/csharp/System.ComponentModel.Design/ComponentChangedEventArgs/Overview/componentchangedeventargsexample.cs Removes unnecessary scaffolding.
snippets/csharp/System.ComponentModel.Design/ArrayEditor/Overview/class1.cs Simplifies the array property.
snippets/csharp/System.ComponentModel.Design/ActiveDesignerEventHandler/Overview/activedesignereventhandlerexample.cs Modernizes event handling.
snippets/csharp/System.ComponentModel.Design/ActiveDesignerEventArgs/Overview/class1.cs Removes unused entry point.
snippets/csharp/System.ComponentModel.Design.Serialization/ResolveNameEventHandler/Overview/form1.cs Modernizes serialization events.
snippets/csharp/System.ComponentModel.Design.Serialization/ResolveNameEventArgs/Overview/class1.cs Cleans signatures and formatting.
snippets/csharp/System.ComponentModel.Design.Serialization/INameCreationService/Overview/class1.cs Modernizes identifier creation.
snippets/csharp/System.ComponentModel.Design.Serialization/DesignerSerializerAttribute/Overview/source.cs Simplifies serializer sample.
snippets/csharp/System.ComponentModel.Design.Serialization/ContextStack/Overview/class1.cs Modernizes stack operations.
snippets/csharp/System.ComponentModel.Design.Serialization/CodeDomSerializerException/Overview/source.cs Removes unused imports and whitespace.
snippets/csharp/System.ComponentModel.Design.Serialization/CodeDomSerializer/Overview/idesignerserializationmanagersample.cs Reformats serializer lookup.
snippets/csharp/System.ComponentModel.Composition/ExportAttribute/program.cs Converts data fields to properties.
snippets/csharp/System.ComponentModel.Composition.Hosting/DirectoryCatalog/consoleapplication7/program.cs Modernizes composition initialization.
snippets/csharp/System.ComponentModel.Composition.Hosting/DirectoryCatalog/classlibrary1/class1.cs Cleans imports and exported data.
snippets/csharp/System.ComponentModel.Composition.Hosting/CompositionContainer/Overview/program.cs Modernizes container setup.
snippets/csharp/System.ComponentModel.Composition.Hosting/CompositionContainer/Compose/program.cs Modernizes composition batch setup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread snippets/csharp/System.ComponentModel/IListSource/Overview/Employee.cs Outdated
Comment thread snippets/csharp/System.ComponentModel/TypeConverterAttribute/Overview/source.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@gewarren
gewarren marked this pull request as ready for review August 24, 2026 15:43
@gewarren
gewarren requested a review from a team as a code owner August 24, 2026 15:43
@gewarren
gewarren merged commit 96f1ca1 into dotnet:main Aug 24, 2026
7 checks passed
@gewarren
gewarren deleted the modernize-system-componentmodel-more branch August 24, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants