diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/CommonUtils.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/CommonUtils.cs index cd2050f3d..e51685365 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/CommonUtils.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/CommonUtils.cs @@ -3,19 +3,14 @@ using System.Collections; using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; - +using System.Resources; +using System.Reflection; namespace Microsoft.PowerShell.Commands.Diagnostics.Common { - internal class CommonUtilities + internal static class CommonUtilities { - // - // No-op private ctor to prevent the default ctor from getting generated. - // This class is intended to only have static members. - // - private CommonUtilities() { } - // // StringArrayToString helper converts a string array into a comma-separated string. // Note this has only limited use, individual strings cannot have commas. @@ -117,6 +112,12 @@ namespace Microsoft.PowerShell.Commands.Diagnostics.Common return formatError; } + public static ResourceManager GetResourceManager() + { + // this naming pattern is dictated by the dotnet cli + return new ResourceManager("Microsoft.PowerShell.Commands.Diagnostics.resources.GetEventResources", typeof(CommonUtilities).GetTypeInfo().Assembly); + } + } } diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/CounterSample.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/CounterSample.cs index 29bdd7845..a7cdd86d1 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/CounterSample.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/CounterSample.cs @@ -145,7 +145,7 @@ namespace Microsoft.PowerShell.Commands.GetCounter { internal PerformanceCounterSampleSet() { - _resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly()); + _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager(); } internal PerformanceCounterSampleSet (DateTime timeStamp, diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/ExportCounterCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/ExportCounterCommand.cs index 9104fc838..49246e66f 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/ExportCounterCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/ExportCounterCommand.cs @@ -152,7 +152,7 @@ namespace Microsoft.PowerShell.Commands protected override void BeginProcessing() { - _resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly()); + _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager(); // // Determine the OS version: this cmdlet requires Windows 7 diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs index b0eac6410..815f10705 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs @@ -203,7 +203,7 @@ namespace Microsoft.PowerShell.Commands // protected override void BeginProcessing() { - _resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly()); + _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager(); _pdhHelper = new PdhHelper(System.Environment.OSVersion.Version.Major < 6); uint res = _pdhHelper.ConnectToDataSource(); diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs index 019c0b014..f8dfa499a 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs @@ -396,7 +396,7 @@ namespace Microsoft.PowerShell.Commands // protected override void BeginProcessing() { - _resourceMgr = new ResourceManager("GetEventResources", typeof(GetWinEventCommand).GetTypeInfo().Assembly); + _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager(); } diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/ImportCounterCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/ImportCounterCommand.cs index a54c5e7b5..ffa460119 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/ImportCounterCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/ImportCounterCommand.cs @@ -189,7 +189,7 @@ namespace Microsoft.PowerShell.Commands // protected override void BeginProcessing() { - _resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly()); + _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager(); _pdhHelper = new PdhHelper(System.Environment.OSVersion.Version.Major < 6); } diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/NewWinEventCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/NewWinEventCommand.cs index 7c4326540..0f80fa729 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/NewWinEventCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/NewWinEventCommand.cs @@ -13,7 +13,7 @@ using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; using System.Xml; using System.IO; - + namespace Microsoft.PowerShell.Commands { /// @@ -28,7 +28,7 @@ namespace Microsoft.PowerShell.Commands private const string TemplateTag = "template"; private const string DataTag = "data"; - private ResourceManager _resourceMgr = new ResourceManager("GetEventResources", typeof(NewWinEventCommand).GetTypeInfo().Assembly); + private ResourceManager _resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager(); /// diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/project.json b/src/Microsoft.PowerShell.Commands.Diagnostics/project.json index 9796030c2..231795604 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/project.json +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/project.json @@ -29,8 +29,7 @@ "ExportCounterCommand.cs", "GetCounterCommand.cs", "ImportCounterCommand.cs", - "CounterFileInfo.cs", - "CommonUtils.cs" + "CounterFileInfo.cs" ] } }