Skip to content

Fix code squigglies and move snippets#51519

Open
gewarren wants to merge 2 commits intodotnet:mainfrom
gewarren:event-handler
Open

Fix code squigglies and move snippets#51519
gewarren wants to merge 2 commits intodotnet:mainfrom
gewarren:event-handler

Conversation

@gewarren
Copy link
Contributor

@gewarren gewarren commented Feb 4, 2026

@gewarren gewarren requested a review from BillWagner as a code owner February 4, 2026 22:53
Copilot AI review requested due to automatic review settings February 4, 2026 22:53
@gewarren gewarren requested review from a team and adegeo as code owners February 4, 2026 22:53
@dotnetrepoman dotnetrepoman bot added this to the February 2026 milestone Feb 4, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/snippets to docs/standard/events/snippets/raise-consume directory
  • 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>
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

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#.

Suggested change
<OutputType>Library</OutputType>
<OutputType>Exe</OutputType>

Copilot uses AI. Check for mistakes.
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

These changes LGTM @gewarren

Let's :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Marking EventHandler declaration as nullable

2 participants