From 7094fee090715edab2faa4158430356d251a402f Mon Sep 17 00:00:00 2001 From: Szymon Kulec Date: Thu, 17 Aug 2017 14:41:53 +0200 Subject: [PATCH 01/10] Expected powershell --- ...CodeGenerationTests.Generates.approved.ps1 | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 index 215f60d..229f29c 100644 --- a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 +++ b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 @@ -5,23 +5,44 @@ Function InstallNSBPerfCounters { $category = @{Name="NServiceBus"; Description="NServiceBus statistics"} $counters = New-Object System.Diagnostics.CounterCreationDataCollection $counters.AddRange(@( - New-Object System.Diagnostics.CounterCreationData "SLA violation countdown", "Seconds until the SLA for this endpoint is breached.", NumberOfItems32 - New-Object System.Diagnostics.CounterCreationData "Critical Time Average", "The time it took from sending to processing the message.", AverageTimer32 - New-Object System.Diagnostics.CounterCreationData "Critical Time AverageBase", "The time it took from sending to processing the message.", AverageBase - New-Object System.Diagnostics.CounterCreationData "Critical Time", "The time it took from sending to processing the message.", NumberOfItems32 - New-Object System.Diagnostics.CounterCreationData "Processing Time Average", "The time it took to successfully process a message.", AverageTimer32 - New-Object System.Diagnostics.CounterCreationData "Processing Time AverageBase", "The time it took to successfully process a message.", AverageBase - New-Object System.Diagnostics.CounterCreationData "Processing Time", "The time it took to successfully process a message.", NumberOfItems32 - New-Object System.Diagnostics.CounterCreationData "# of msgs failures / sec", "The current number of failed processed messages by the transport per second.", RateOfCountsPerSecond32 - New-Object System.Diagnostics.CounterCreationData "# of msgs successfully processed / sec", "The current number of messages processed successfully by the transport per second.", RateOfCountsPerSecond32 - New-Object System.Diagnostics.CounterCreationData "# of msgs pulled from the input queue /sec", "The current number of messages pulled from the input queue by the transport per second.", RateOfCountsPerSecond32 - New-Object System.Diagnostics.CounterCreationData "Retries", "A message has been scheduled for retry (FLR or SLR)", RateOfCountsPerSecond32 + New-Object System.Diagnostics.CounterCreationData "SLA violation countdown", "Seconds until the SLA for this endpoint is breached.", NumberOfItems32 + New-Object System.Diagnostics.CounterCreationData "Critical Time Average", "The time it took from sending to processing the message.", AverageTimer32 + New-Object System.Diagnostics.CounterCreationData "Critical Time AverageBase", "The time it took from sending to processing the message.", AverageBase + New-Object System.Diagnostics.CounterCreationData "Critical Time", "The time it took from sending to processing the message.", NumberOfItems32 + New-Object System.Diagnostics.CounterCreationData "Processing Time Average", "The time it took to successfully process a message.", AverageTimer32 + New-Object System.Diagnostics.CounterCreationData "Processing Time AverageBase", "The time it took to successfully process a message.", AverageBase + New-Object System.Diagnostics.CounterCreationData "Processing Time", "The time it took to successfully process a message.", NumberOfItems32 + New-Object System.Diagnostics.CounterCreationData "# of msgs failures / sec", "The current number of failed processed messages by the transport per second.", RateOfCountsPerSecond32 + New-Object System.Diagnostics.CounterCreationData "# of msgs successfully processed / sec", "The current number of messages processed successfully by the transport per second.", RateOfCountsPerSecond32 + New-Object System.Diagnostics.CounterCreationData "# of msgs pulled from the input queue /sec", "The current number of messages pulled from the input queue by the transport per second.", RateOfCountsPerSecond32 + New-Object System.Diagnostics.CounterCreationData "Retries", "A message has been scheduled for retry (FLR or SLR)", RateOfCountsPerSecond32 )) - if ([System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { - [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) + + $shouldCreate = $true + if ([System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { + + $shouldCreate = $false + + foreach($counter in $counters){ + $exists = [System.Diagnostics.PerformanceCounterCategory]::CounterExists($counter.CounterName, $category.Name) + if (!$exists){ + Write-Host "One or more counters are missing. The performance counter category will be recreated" + $shouldCreate = $true + [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) + break + } + } } - [void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters) + + if ($shouldCreate){ + Write-Host "Creating the performance counter category" + [void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters) + } + else { + Write-Host "No performance counters have to be created" + } + [System.Diagnostics.PerformanceCounter]::CloseSharedResources() } InstallNSBPerfCounters From 850f48bda381485fe058ab2859ea2241772539c8 Mon Sep 17 00:00:00 2001 From: Tomasz Masternak Date: Tue, 12 Sep 2017 16:33:50 +0200 Subject: [PATCH 02/10] minor tweaks to ps1 approved script --- .../PowershellCodeGenerationTests.Generates.approved.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 index 229f29c..c565772 100644 --- a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 +++ b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 @@ -16,7 +16,6 @@ Function InstallNSBPerfCounters { New-Object System.Diagnostics.CounterCreationData "# of msgs successfully processed / sec", "The current number of messages processed successfully by the transport per second.", RateOfCountsPerSecond32 New-Object System.Diagnostics.CounterCreationData "# of msgs pulled from the input queue /sec", "The current number of messages pulled from the input queue by the transport per second.", RateOfCountsPerSecond32 New-Object System.Diagnostics.CounterCreationData "Retries", "A message has been scheduled for retry (FLR or SLR)", RateOfCountsPerSecond32 - )) $shouldCreate = $true @@ -27,15 +26,16 @@ Function InstallNSBPerfCounters { foreach($counter in $counters){ $exists = [System.Diagnostics.PerformanceCounterCategory]::CounterExists($counter.CounterName, $category.Name) if (!$exists){ - Write-Host "One or more counters are missing. The performance counter category will be recreated" $shouldCreate = $true - [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) break } } } if ($shouldCreate){ + Write-Host "One or more counters are missing. The performance counter category will be recreated" + [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) + Write-Host "Creating the performance counter category" [void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters) } @@ -45,4 +45,4 @@ Function InstallNSBPerfCounters { [System.Diagnostics.PerformanceCounter]::CloseSharedResources() } -InstallNSBPerfCounters +InstallNSBPerfCounters \ No newline at end of file From 51764599cc0f06664a59adcfc3496a18be5faded Mon Sep 17 00:00:00 2001 From: Tomasz Masternak Date: Tue, 12 Sep 2017 16:54:54 +0200 Subject: [PATCH 03/10] simpler approved script version --- ...ershellCodeGenerationTests.Generates.approved.ps1 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 index c565772..2d15c6b 100644 --- a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 +++ b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 @@ -18,24 +18,20 @@ Function InstallNSBPerfCounters { New-Object System.Diagnostics.CounterCreationData "Retries", "A message has been scheduled for retry (FLR or SLR)", RateOfCountsPerSecond32 )) - $shouldCreate = $true if ([System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { - $shouldCreate = $false - foreach($counter in $counters){ $exists = [System.Diagnostics.PerformanceCounterCategory]::CounterExists($counter.CounterName, $category.Name) if (!$exists){ - $shouldCreate = $true + Write-Host "One or more counters are missing. The performance counter category will be recreated" + [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) + break } } } - if ($shouldCreate){ - Write-Host "One or more counters are missing. The performance counter category will be recreated" - [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) - + if (![System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { Write-Host "Creating the performance counter category" [void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters) } From 9bf4ab7d319b75341339ba2c7650b2c9eae4a1a8 Mon Sep 17 00:00:00 2001 From: Tomasz Masternak Date: Tue, 12 Sep 2017 16:55:02 +0200 Subject: [PATCH 04/10] cs script approved version --- ...pCodeGenerationTests.Generates.approved.cs | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/ScriptBuilderTask.Tests/CSharpCodeGenerationTests.Generates.approved.cs b/src/ScriptBuilderTask.Tests/CSharpCodeGenerationTests.Generates.approved.cs index 9c6659d..de6ba84 100644 --- a/src/ScriptBuilderTask.Tests/CSharpCodeGenerationTests.Generates.approved.cs +++ b/src/ScriptBuilderTask.Tests/CSharpCodeGenerationTests.Generates.approved.cs @@ -4,27 +4,39 @@ using System.Runtime.CompilerServices; [CompilerGenerated] -public static class CounterCreator +public static class CounterCreator { - public static void Create() + public static void Create() { var counterCreationCollection = new CounterCreationDataCollection(Counters); try { var categoryName = "NServiceBus"; + if (PerformanceCounterCategory.Exists(categoryName)) { - PerformanceCounterCategory.Delete(categoryName); + foreach (CounterCreationData counter in counterCreationCollection) + { + if (!PerformanceCounterCategory.CounterExists(counter.CounterName, categoryName)) + { + PerformanceCounterCategory.Delete(categoryName); + break; + } + } + } + + if (PerformanceCounterCategory.Exists(categoryName) == false) + { + PerformanceCounterCategory.Create( + categoryName: categoryName, + categoryHelp: "NServiceBus statistics", + categoryType: PerformanceCounterCategoryType.MultiInstance, + counterData: counterCreationCollection); } - PerformanceCounterCategory.Create( - categoryName: categoryName, - categoryHelp: "NServiceBus statistics", - categoryType: PerformanceCounterCategoryType.MultiInstance, - counterData: counterCreationCollection); PerformanceCounter.CloseSharedResources(); } - catch (Exception ex) when (ex is SecurityException || ex is UnauthorizedAccessException) + catch (Exception ex) when(ex is SecurityException || ex is UnauthorizedAccessException) { throw new Exception("Execution requires elevated permissions", ex); } From 7085f8487aec6f7d7846af9be595e09118ac9980 Mon Sep 17 00:00:00 2001 From: Tomasz Masternak Date: Thu, 14 Sep 2017 09:30:52 +0200 Subject: [PATCH 05/10] csharp counter writer --- src/ScriptBuilderTask/CSharpCounterWriter.cs | 33 ++++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/ScriptBuilderTask/CSharpCounterWriter.cs b/src/ScriptBuilderTask/CSharpCounterWriter.cs index 2e0e2bb..14616c0 100644 --- a/src/ScriptBuilderTask/CSharpCounterWriter.cs +++ b/src/ScriptBuilderTask/CSharpCounterWriter.cs @@ -36,7 +36,8 @@ public static void WriteCode(string scriptPath, IEnumerable foreach (var signal in signals) { - legacyInstanceNameMap.TryGetValue(signal.Name, out var instanceName); + string instanceName; + legacyInstanceNameMap.TryGetValue(signal.Name, out instanceName); var signalDefinition = $@"new CounterCreationData(""{instanceName ?? signal.Name}"", ""{signal.Description}"", PerformanceCounterType.RateOfCountsPerSecond32),"; stringBuilder.AppendLine(signalDefinition.PadLeft(signalDefinition.Length + 8)); @@ -52,27 +53,39 @@ public static void WriteCode(string scriptPath, IEnumerable using System.Runtime.CompilerServices; [CompilerGenerated] -public static class CounterCreator +public static class CounterCreator {{ - public static void Create() + public static void Create() {{ var counterCreationCollection = new CounterCreationDataCollection(Counters); try {{ var categoryName = ""NServiceBus""; + if (PerformanceCounterCategory.Exists(categoryName)) {{ - PerformanceCounterCategory.Delete(categoryName); + foreach (CounterCreationData counter in counterCreationCollection) + {{ + if (!PerformanceCounterCategory.CounterExists(counter.CounterName, categoryName)) + {{ + PerformanceCounterCategory.Delete(categoryName); + break; + }} + }} + }} + + if (PerformanceCounterCategory.Exists(categoryName) == false) + {{ + PerformanceCounterCategory.Create( + categoryName: categoryName, + categoryHelp: ""NServiceBus statistics"", + categoryType: PerformanceCounterCategoryType.MultiInstance, + counterData: counterCreationCollection); }} - PerformanceCounterCategory.Create( - categoryName: categoryName, - categoryHelp: ""NServiceBus statistics"", - categoryType: PerformanceCounterCategoryType.MultiInstance, - counterData: counterCreationCollection); PerformanceCounter.CloseSharedResources(); }} - catch (Exception ex) when (ex is SecurityException || ex is UnauthorizedAccessException) + catch (Exception ex) when(ex is SecurityException || ex is UnauthorizedAccessException) {{ throw new Exception(""Execution requires elevated permissions"", ex); }} From c5e6b368ef1314d625e5e62ec0ec8890033806b2 Mon Sep 17 00:00:00 2001 From: Tomasz Masternak Date: Thu, 14 Sep 2017 11:16:01 +0200 Subject: [PATCH 06/10] powershel generator fixes --- .../PowerShellCounterWriter.cs | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/ScriptBuilderTask/PowerShellCounterWriter.cs b/src/ScriptBuilderTask/PowerShellCounterWriter.cs index 7c5b6c5..fbfd2fb 100644 --- a/src/ScriptBuilderTask/PowerShellCounterWriter.cs +++ b/src/ScriptBuilderTask/PowerShellCounterWriter.cs @@ -25,8 +25,8 @@ public static void WriteScript(string scriptPath, IEnumerable Date: Thu, 14 Sep 2017 13:18:45 +0200 Subject: [PATCH 07/10] registering ps1 as valid text format for approvals --- src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.cs b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.cs index 811fe5c..b4e94b9 100644 --- a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.cs +++ b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Runtime.CompilerServices; using ApprovalTests; + using ApprovalTests.Reporters; using NServiceBus.Metrics.PerformanceCounters; using NUnit.Framework; @@ -34,6 +35,8 @@ public void SetUp() [MethodImpl(MethodImplOptions.NoInlining)] public void Generates() { + GenericDiffReporter.RegisterTextFileTypes(".ps1"); + task.Execute(); var powershell = Directory.EnumerateFiles(tempPath, "*.ps1", SearchOption.AllDirectories).Single(); From f7cabd2716b70ced3b66c56acb7bb5054d24df32 Mon Sep 17 00:00:00 2001 From: Tomasz Masternak Date: Thu, 14 Sep 2017 13:19:05 +0200 Subject: [PATCH 08/10] fixing whitespace differences for ps script --- ...CodeGenerationTests.Generates.approved.ps1 | 61 ++++++++++--------- .../PowerShellCounterWriter.cs | 11 ++-- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 index 2d15c6b..53d1d67 100644 --- a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 +++ b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.Generates.approved.ps1 @@ -1,44 +1,45 @@ #requires -RunAsAdministrator Function InstallNSBPerfCounters { - + $category = @{Name="NServiceBus"; Description="NServiceBus statistics"} $counters = New-Object System.Diagnostics.CounterCreationDataCollection $counters.AddRange(@( - New-Object System.Diagnostics.CounterCreationData "SLA violation countdown", "Seconds until the SLA for this endpoint is breached.", NumberOfItems32 - New-Object System.Diagnostics.CounterCreationData "Critical Time Average", "The time it took from sending to processing the message.", AverageTimer32 - New-Object System.Diagnostics.CounterCreationData "Critical Time AverageBase", "The time it took from sending to processing the message.", AverageBase - New-Object System.Diagnostics.CounterCreationData "Critical Time", "The time it took from sending to processing the message.", NumberOfItems32 - New-Object System.Diagnostics.CounterCreationData "Processing Time Average", "The time it took to successfully process a message.", AverageTimer32 - New-Object System.Diagnostics.CounterCreationData "Processing Time AverageBase", "The time it took to successfully process a message.", AverageBase - New-Object System.Diagnostics.CounterCreationData "Processing Time", "The time it took to successfully process a message.", NumberOfItems32 - New-Object System.Diagnostics.CounterCreationData "# of msgs failures / sec", "The current number of failed processed messages by the transport per second.", RateOfCountsPerSecond32 - New-Object System.Diagnostics.CounterCreationData "# of msgs successfully processed / sec", "The current number of messages processed successfully by the transport per second.", RateOfCountsPerSecond32 - New-Object System.Diagnostics.CounterCreationData "# of msgs pulled from the input queue /sec", "The current number of messages pulled from the input queue by the transport per second.", RateOfCountsPerSecond32 - New-Object System.Diagnostics.CounterCreationData "Retries", "A message has been scheduled for retry (FLR or SLR)", RateOfCountsPerSecond32 + New-Object System.Diagnostics.CounterCreationData "SLA violation countdown", "Seconds until the SLA for this endpoint is breached.", NumberOfItems32 + New-Object System.Diagnostics.CounterCreationData "Critical Time Average", "The time it took from sending to processing the message.", AverageTimer32 + New-Object System.Diagnostics.CounterCreationData "Critical Time AverageBase", "The time it took from sending to processing the message.", AverageBase + New-Object System.Diagnostics.CounterCreationData "Critical Time", "The time it took from sending to processing the message.", NumberOfItems32 + New-Object System.Diagnostics.CounterCreationData "Processing Time Average", "The time it took to successfully process a message.", AverageTimer32 + New-Object System.Diagnostics.CounterCreationData "Processing Time AverageBase", "The time it took to successfully process a message.", AverageBase + New-Object System.Diagnostics.CounterCreationData "Processing Time", "The time it took to successfully process a message.", NumberOfItems32 + New-Object System.Diagnostics.CounterCreationData "# of msgs failures / sec", "The current number of failed processed messages by the transport per second.", RateOfCountsPerSecond32 + New-Object System.Diagnostics.CounterCreationData "# of msgs successfully processed / sec", "The current number of messages processed successfully by the transport per second.", RateOfCountsPerSecond32 + New-Object System.Diagnostics.CounterCreationData "# of msgs pulled from the input queue /sec", "The current number of messages pulled from the input queue by the transport per second.", RateOfCountsPerSecond32 + New-Object System.Diagnostics.CounterCreationData "Retries", "A message has been scheduled for retry (FLR or SLR)", RateOfCountsPerSecond32 + )) - if ([System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { - - foreach($counter in $counters){ - $exists = [System.Diagnostics.PerformanceCounterCategory]::CounterExists($counter.CounterName, $category.Name) - if (!$exists){ - Write-Host "One or more counters are missing. The performance counter category will be recreated" - [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) + if ([System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { + + foreach($counter in $counters){ + $exists = [System.Diagnostics.PerformanceCounterCategory]::CounterExists($counter.CounterName, $category.Name) + if (!$exists){ + Write-Host "One or more counters are missing.The performance counter category will be recreated" + [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name) - break - } - } + break + } + } } - if (![System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { + if (![System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) { Write-Host "Creating the performance counter category" - [void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters) - } - else { - Write-Host "No performance counters have to be created" - } - + [void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters) + } + else { + Write-Host "No performance counters have to be created" + } + [System.Diagnostics.PerformanceCounter]::CloseSharedResources() } -InstallNSBPerfCounters \ No newline at end of file +InstallNSBPerfCounters diff --git a/src/ScriptBuilderTask/PowerShellCounterWriter.cs b/src/ScriptBuilderTask/PowerShellCounterWriter.cs index fbfd2fb..53ca6ed 100644 --- a/src/ScriptBuilderTask/PowerShellCounterWriter.cs +++ b/src/ScriptBuilderTask/PowerShellCounterWriter.cs @@ -50,7 +50,7 @@ public static void WriteScript(string scriptPath, IEnumerable Date: Fri, 15 Sep 2017 10:05:55 +0200 Subject: [PATCH 09/10] inlining out params in script wirters --- src/ScriptBuilderTask/CSharpCounterWriter.cs | 3 +-- src/ScriptBuilderTask/PowerShellCounterWriter.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ScriptBuilderTask/CSharpCounterWriter.cs b/src/ScriptBuilderTask/CSharpCounterWriter.cs index 14616c0..ccb4f40 100644 --- a/src/ScriptBuilderTask/CSharpCounterWriter.cs +++ b/src/ScriptBuilderTask/CSharpCounterWriter.cs @@ -36,8 +36,7 @@ public static void WriteCode(string scriptPath, IEnumerable foreach (var signal in signals) { - string instanceName; - legacyInstanceNameMap.TryGetValue(signal.Name, out instanceName); + legacyInstanceNameMap.TryGetValue(signal.Name, out string instanceName); var signalDefinition = $@"new CounterCreationData(""{instanceName ?? signal.Name}"", ""{signal.Description}"", PerformanceCounterType.RateOfCountsPerSecond32),"; stringBuilder.AppendLine(signalDefinition.PadLeft(signalDefinition.Length + 8)); diff --git a/src/ScriptBuilderTask/PowerShellCounterWriter.cs b/src/ScriptBuilderTask/PowerShellCounterWriter.cs index 53ca6ed..34e0bd5 100644 --- a/src/ScriptBuilderTask/PowerShellCounterWriter.cs +++ b/src/ScriptBuilderTask/PowerShellCounterWriter.cs @@ -36,8 +36,7 @@ public static void WriteScript(string scriptPath, IEnumerable Date: Fri, 15 Sep 2017 11:56:42 +0200 Subject: [PATCH 10/10] var instead of type delcarations --- src/ScriptBuilderTask/CSharpCounterWriter.cs | 2 +- src/ScriptBuilderTask/PowerShellCounterWriter.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ScriptBuilderTask/CSharpCounterWriter.cs b/src/ScriptBuilderTask/CSharpCounterWriter.cs index ccb4f40..22d2459 100644 --- a/src/ScriptBuilderTask/CSharpCounterWriter.cs +++ b/src/ScriptBuilderTask/CSharpCounterWriter.cs @@ -36,7 +36,7 @@ public static void WriteCode(string scriptPath, IEnumerable foreach (var signal in signals) { - legacyInstanceNameMap.TryGetValue(signal.Name, out string instanceName); + legacyInstanceNameMap.TryGetValue(signal.Name, out var instanceName); var signalDefinition = $@"new CounterCreationData(""{instanceName ?? signal.Name}"", ""{signal.Description}"", PerformanceCounterType.RateOfCountsPerSecond32),"; stringBuilder.AppendLine(signalDefinition.PadLeft(signalDefinition.Length + 8)); diff --git a/src/ScriptBuilderTask/PowerShellCounterWriter.cs b/src/ScriptBuilderTask/PowerShellCounterWriter.cs index 34e0bd5..461e338 100644 --- a/src/ScriptBuilderTask/PowerShellCounterWriter.cs +++ b/src/ScriptBuilderTask/PowerShellCounterWriter.cs @@ -36,7 +36,7 @@ public static void WriteScript(string scriptPath, IEnumerable