From a08b3b1d9fb0dfa37b43fc8ede6d91ba6514b337 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 31 Jul 2025 15:57:10 +0000 Subject: [PATCH 1/2] Initial plan From 24013b148d580258ea293cb44188da1b228063d1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 31 Jul 2025 16:03:48 +0000 Subject: [PATCH 2/2] Fix nullable event warning in interface events documentation Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> --- .../events/how-to-implement-interface-events.md | 2 +- .../VS_Snippets_VBCSharp/csProgGuideEvents/CS/Events.cs | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/csharp/programming-guide/events/how-to-implement-interface-events.md b/docs/csharp/programming-guide/events/how-to-implement-interface-events.md index 0561e4e77ad91..81c49af87d8fd 100644 --- a/docs/csharp/programming-guide/events/how-to-implement-interface-events.md +++ b/docs/csharp/programming-guide/events/how-to-implement-interface-events.md @@ -29,7 +29,7 @@ namespace ImplementInterfaceEvents } public class Shape : IDrawingObject { - public event EventHandler ShapeChanged; + public event EventHandler? ShapeChanged; void ChangeShape() { // Do something here before the event… diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideEvents/CS/Events.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideEvents/CS/Events.cs index 20f6f0797ce1d..6a959a4e65448 100644 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideEvents/CS/Events.cs +++ b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideEvents/CS/Events.cs @@ -686,10 +686,10 @@ public class MyEventArgs : EventArgs } public class Shape : IDrawingObject { - public event EventHandler ShapeChanged; + public event EventHandler? ShapeChanged; void ChangeShape() { - // Do something here before the event� + // Do something here before the event… OnShapeChanged(new MyEventArgs(/*arguments*/)); @@ -697,10 +697,7 @@ void ChangeShape() } protected virtual void OnShapeChanged(MyEventArgs e) { - if (ShapeChanged != null) - { - ShapeChanged(this, e); - } + ShapeChanged?.Invoke(this, e); } } }