From 9343bd1cc72eeed3b0d2a230db7fc5b5243bb225 Mon Sep 17 00:00:00 2001 From: David Pine Date: Mon, 31 Oct 2022 09:59:34 -0500 Subject: [PATCH 1/2] Short-hand event handler invocation --- .../VS_Snippets_CLR/eventsoverview/cs/programtruncated.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programtruncated.cs b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programtruncated.cs index ac747b434e5b2..4aa1a74a89570 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programtruncated.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programtruncated.cs @@ -27,8 +27,7 @@ class Counter protected virtual void OnThresholdReached(EventArgs e) { - EventHandler handler = ThresholdReached; - handler?.Invoke(this, e); + ThresholdReached?.Invoke(this, e); } // provide remaining implementation for the class From 1c942b32a3120793e5502183535b7af95f554d51 Mon Sep 17 00:00:00 2001 From: David Pine Date: Mon, 31 Oct 2022 12:51:26 -0500 Subject: [PATCH 2/2] Fix collisions and add csproj --- .../eventsoverview/cs/eventsoverview.csproj | 11 +++++++++++ .../eventsoverview/cs/programnodata.cs | 2 +- .../eventsoverview/cs/programtruncated.cs | 4 ++-- .../eventsoverview/cs/programwithdata.cs | 4 ++-- .../eventsoverview/cs/programwithdelegate.cs | 4 ++-- 5 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/eventsoverview.csproj diff --git a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/eventsoverview.csproj b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/eventsoverview.csproj new file mode 100644 index 0000000000000..0be2a52725e5e --- /dev/null +++ b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/eventsoverview.csproj @@ -0,0 +1,11 @@ + + + + net6.0 + disable + true + Exe + ConsoleApplication2.ProgramTwo + + + \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programnodata.cs b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programnodata.cs index 654c0db5078de..ea92dd0b743c6 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programnodata.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programnodata.cs @@ -3,7 +3,7 @@ namespace ConsoleApplication1 { - class Program + class ProgramOne { static void Main(string[] args) { diff --git a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programtruncated.cs b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programtruncated.cs index 4aa1a74a89570..3507c52fb8a80 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programtruncated.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programtruncated.cs @@ -1,9 +1,9 @@ using System; -namespace ConsoleApplication1 +namespace ConsoleApplication2 { // - class Program + class ProgramTwo { static void Main() { diff --git a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programwithdata.cs b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programwithdata.cs index 3a49caa9e1bac..5700f9b2bdb6d 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programwithdata.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programwithdata.cs @@ -1,9 +1,9 @@ // using System; -namespace ConsoleApplication1 +namespace ConsoleApplication3 { - class Program + class ProgramThree { static void Main(string[] args) { diff --git a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programwithdelegate.cs b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programwithdelegate.cs index b063190ff9467..7ef1d2fd7ba5e 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programwithdelegate.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR/eventsoverview/cs/programwithdelegate.cs @@ -1,9 +1,9 @@ // using System; -namespace ConsoleApplication1 +namespace ConsoleApplication4 { - class Program + class ProgramFour { static void Main(string[] args) {