Fix code squigglies and move snippets#51519
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request addresses issue #42459 by fixing compiler warnings related to nullable EventHandler declarations and relocating code snippets to a more appropriate directory structure.
Changes:
- Adds nullable annotations to EventHandler declarations in C# examples to resolve CS8618 warnings
- Moves Visual Basic and C# code snippets from
samples/snippetstodocs/standard/events/snippets/raise-consumedirectory - Updates markdown documentation to reference the new snippet locations and improves title casing
- Modernizes C# code with primary constructors, target-typed new expressions, and nullable-aware patterns
- Updates target framework from net8.0 to net10.0
Reviewed changes
Copilot reviewed 15 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| docs/standard/events/how-to-raise-and-consume-events.md | Updates snippet paths, applies sentence case to title, fixes xref format for generic EventHandler |
| docs/standard/events/snippets/raise-consume/csharp/*.cs | Adds nullable event handlers, modernizes syntax, moves from old location |
| docs/standard/events/snippets/raise-consume/csharp/project.csproj | Updates target framework to net10.0 |
| docs/standard/events/snippets/raise-consume/vb/*.vb | Refactors to use underscored field naming, wraps in namespaces, moves from old location |
| docs/standard/events/snippets/raise-consume/vb/project.vbproj | New VB project file targeting net10.0 with Library output type |
| samples/snippets/visualbasic/VS_Snippets_CLR/eventsoverview/vb/*.vb | Deletes old VB snippet files |
| docs/standard/events/snippets/raise-consume/csharp/eventsoverview/* | Adds Visual Studio IDE cache and binary files (should not be committed) |
Comments suppressed due to low confidence (1)
docs/standard/events/snippets/raise-consume/csharp/project.csproj:4
- The target framework is set to net10.0, but .NET 10 has not been released yet (as of February 2026). The latest stable .NET version is .NET 9. Using a preview or unreleased version in documentation code samples can cause build failures for users trying to run the examples. Consider using net9.0 or the latest stable version unless there's a specific requirement for .NET 10 features.
| <TargetFramework>net10.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>true</ImplicitUsings> | ||
| <OutputType>Library</OutputType> |
There was a problem hiding this comment.
The Visual Basic project file is configured with OutputType as Library, which means it won't be executable. For consistency with the C# examples which have OutputType as Exe, this should also be Exe if you want these snippets to be runnable standalone examples. If Library is intentional for VB, please clarify why the approach differs from C#.
| <OutputType>Library</OutputType> | |
| <OutputType>Exe</OutputType> |
BillWagner
left a comment
There was a problem hiding this comment.
These changes LGTM @gewarren
Let's ![]()
Fixes #42459
Internal previews