Fix GetEventResources problem in Microsoft.PowerShell.Commands.Diagnostics

-Move logic about instantiating ResourceManager in one place
-Add CommonUtils.cs to CoreCLR build
-Update resources generation with dotnet cli naming pattern
This commit is contained in:
Sergei Vorobev committed 2016-07-01 12:20:48 -07:00
1 parent 8d22c75fe8
commit b755212f5d
8 files changed
+17 -17

No files matched your search

@@ -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);
}
}
}
@@ -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,
@@ -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
@@ -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();
@@ -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();
}
@@ -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);
}
@@ -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();
/// <summary>
@@ -29,8 +29,7 @@
"ExportCounterCommand.cs",
"GetCounterCommand.cs",
"ImportCounterCommand.cs",
"CounterFileInfo.cs",
"CommonUtils.cs"
"CounterFileInfo.cs"
]
}
}