Repository navigation
adding microsoft.powershell.diagnostics.dll to build #1111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d1015ed
Add project.json to src/Microsoft.PowerShell.Commands.Diagnostics/pro…
chunqingchen 29271ec
Add map.json to src/Microsoft.PowerShell.Commands.Diagnostics
chunqingchen 61ea879
Add AssemblyInfo for Diagnostics
4e4a07c
Copy files for Microsoft.PowerShell.Commands.Diagnostics [SD:714215]
PowerShellTeam 7f7ce06
Fix project.json in diagnostics
d578e5f
update project.json for consolehost to include microsoft.powershell.d…
37e7865
Fix project.json and map.json in Microsoft.PowerShell.Commands.Diagno…
549eb64
Copy resources files for Microsoft.PowerShell.Commands.Diagnostics [S…
PowerShellTeam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/Microsoft.PowerShell.Commands.Diagnostics/AssemblyInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using System.Reflection; | ||
| using System.Resources; | ||
|
|
||
| [assembly:AssemblyFileVersionAttribute("3.0.0.0")] | ||
| [assembly:AssemblyVersion("3.0.0.0")] | ||
|
|
||
| [assembly:AssemblyCulture("")] | ||
| [assembly:NeutralResourcesLanguage("en-US")] | ||
|
|
||
| #if !CORECLR | ||
| [assembly:AssemblyKeyFileAttribute(@"..\signing\visualstudiopublic.snk")] | ||
| [assembly:AssemblyDelaySignAttribute(true)] | ||
| #endif | ||
122 changes: 122 additions & 0 deletions
122
src/Microsoft.PowerShell.Commands.Diagnostics/CommonUtils.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| using System; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the wrong SD changeset to import these files from. These must be copied from the latest tag, i.e. SD changeset 709776. We cannot maintain the sync if the sources are imported from random changesets. |
||
| using System.Collections; | ||
| using System.Diagnostics; | ||
| using System.Runtime.InteropServices; | ||
| using System.Text; | ||
|
|
||
|
|
||
| namespace Microsoft.PowerShell.Commands.Diagnostics.Common | ||
| { | ||
|
|
||
| internal 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. | ||
| // | ||
| public static string StringArrayToString (IEnumerable input) | ||
| { | ||
| string ret = ""; | ||
| foreach (string element in input) | ||
| { | ||
| ret += element + ", "; | ||
| } | ||
|
|
||
| ret = ret.TrimEnd(); | ||
| ret = ret.TrimEnd(','); | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
|
|
||
| const uint FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; | ||
| const uint FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; | ||
| const uint FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; | ||
| const uint LOAD_LIBRARY_AS_DATAFILE = 0x00000002; | ||
| const uint FORMAT_MESSAGE_FROM_HMODULE = 0x00000800; | ||
|
|
||
| [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] | ||
| private static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, | ||
| uint dwMessageId, uint dwLanguageId, | ||
| [MarshalAs(UnmanagedType.LPWStr)] | ||
| StringBuilder lpBuffer, | ||
| uint nSize, IntPtr Arguments); | ||
|
|
||
| [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] | ||
| private static extern IntPtr LoadLibraryEx( | ||
| [MarshalAs(UnmanagedType.LPWStr)] string lpFileName, | ||
| IntPtr hFile, | ||
| uint dwFlags | ||
| ); | ||
|
|
||
| [DllImport("kernel32.dll")] | ||
| private static extern bool FreeLibrary(IntPtr hModule); | ||
|
|
||
|
|
||
| [DllImport("kernel32.dll", EntryPoint = "GetUserDefaultLangID", CallingConvention = CallingConvention.Winapi, SetLastError = true)] | ||
| private static extern ushort GetUserDefaultLangID(); | ||
|
|
||
|
|
||
| public static uint FormatMessageFromModule(uint lastError, string moduleName, out String msg) | ||
| { | ||
| Debug.Assert (!string.IsNullOrEmpty(moduleName)); | ||
|
|
||
| uint formatError = 0; | ||
| msg = String.Empty; | ||
| IntPtr moduleHandle = IntPtr.Zero; | ||
|
|
||
| moduleHandle = LoadLibraryEx(moduleName, IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE); | ||
| if (moduleHandle == IntPtr.Zero) | ||
| { | ||
| return (uint)Marshal.GetLastWin32Error(); | ||
| } | ||
|
|
||
| try | ||
| { | ||
| uint dwFormatFlags = FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE; | ||
| uint LANGID = (uint)GetUserDefaultLangID(); | ||
| uint langError = (uint)Marshal.GetLastWin32Error(); | ||
| if (langError != 0) | ||
| { | ||
| LANGID = 0; // neutral | ||
| } | ||
|
|
||
| StringBuilder outStringBuilder = new StringBuilder(1024); | ||
| uint nChars = FormatMessage(dwFormatFlags, | ||
| moduleHandle, | ||
| lastError, | ||
| LANGID, | ||
| outStringBuilder, | ||
| (uint)outStringBuilder.Capacity, | ||
| IntPtr.Zero); | ||
|
|
||
| if (nChars == 0) | ||
| { | ||
| formatError = (uint)Marshal.GetLastWin32Error(); | ||
| //Console.WriteLine("Win32FormatMessage", String.Format(null, "Error formatting message: {0}", formatError)); | ||
| } | ||
| else | ||
| { | ||
| msg = outStringBuilder.ToString(); | ||
| if (msg.EndsWith(Environment.NewLine, StringComparison.Ordinal)) | ||
| { | ||
| msg = msg.Substring(0, msg.Length - 2); | ||
| } | ||
| } | ||
| } | ||
| finally | ||
| { | ||
| FreeLibrary(moduleHandle); | ||
| } | ||
| return formatError; | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
60 changes: 60 additions & 0 deletions
60
src/Microsoft.PowerShell.Commands.Diagnostics/CounterFileInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // | ||
| // Copyright (c) 2008 Microsoft Corporation. All rights reserved. | ||
| // | ||
|
|
||
| using System; | ||
| using System.Collections; | ||
| using System.Collections.Specialized; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.ComponentModel; | ||
|
|
||
| namespace Microsoft.PowerShell.Commands.GetCounter | ||
| { | ||
|
|
||
|
|
||
| public class CounterFileInfo | ||
| { | ||
| internal CounterFileInfo(DateTime oldestRecord, | ||
| DateTime newestRecord, | ||
| UInt32 sampleCount) | ||
| { | ||
|
|
||
| _oldestRecord = oldestRecord; | ||
| _newestRecord = newestRecord; | ||
| _sampleCount = sampleCount; | ||
| } | ||
|
|
||
| internal CounterFileInfo(){} | ||
|
|
||
| public DateTime OldestRecord | ||
| { | ||
| get | ||
| { | ||
| return _oldestRecord; | ||
| } | ||
| } | ||
| private DateTime _oldestRecord = DateTime.MinValue; | ||
|
|
||
| public DateTime NewestRecord | ||
| { | ||
| get | ||
| { | ||
| return _newestRecord; | ||
| } | ||
| } | ||
| private DateTime _newestRecord = DateTime.MaxValue; | ||
|
|
||
| public UInt32 SampleCount | ||
| { | ||
| get | ||
| { | ||
| return _sampleCount; | ||
| } | ||
| } | ||
| private UInt32 _sampleCount = 0; | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
180 changes: 180 additions & 0 deletions
180
src/Microsoft.PowerShell.Commands.Diagnostics/CounterSample.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| // | ||
| // Copyright (c) 2008 Microsoft Corporation. All rights reserved. | ||
| // | ||
|
|
||
|
|
||
| using System; | ||
| using System.Reflection; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.ComponentModel; | ||
| using System.Resources; | ||
| using Microsoft.Powershell.Commands.GetCounter.PdhNative; | ||
| using System.Globalization; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
|
|
||
| namespace Microsoft.PowerShell.Commands.GetCounter | ||
| { | ||
|
|
||
| public class PerformanceCounterSample | ||
| { | ||
| internal PerformanceCounterSample() | ||
| { | ||
| } | ||
|
|
||
| internal PerformanceCounterSample(string path, | ||
| string instanceName, | ||
| double cookedValue, | ||
| UInt64 rawValue, | ||
| UInt64 secondValue, | ||
| uint multiCount, | ||
| PerformanceCounterType counterType, | ||
| UInt32 defaultScale, | ||
| UInt64 timeBase, | ||
| DateTime timeStamp, | ||
| UInt64 timeStamp100nSec, | ||
| UInt32 status) | ||
| { | ||
| _path = path; | ||
| _instanceName = instanceName; | ||
| _cookedValue = cookedValue; | ||
| _rawValue = rawValue; | ||
| _secondValue = secondValue; | ||
| _multiCount = multiCount; | ||
| _counterType = counterType; | ||
| _defaultScale = defaultScale; | ||
| _timeBase = timeBase; | ||
| _timeStamp = timeStamp; | ||
| _timeStamp100nSec = timeStamp100nSec; | ||
| _status = status; | ||
| } | ||
|
|
||
| public string Path | ||
| { | ||
| get {return _path;} | ||
| set {_path = value;} | ||
| } | ||
| private string _path = ""; | ||
|
|
||
|
|
||
| public string InstanceName | ||
| { | ||
| get {return _instanceName;} | ||
| set {_instanceName = value;} | ||
| } | ||
| private string _instanceName = ""; | ||
|
|
||
|
|
||
| public double CookedValue | ||
| { | ||
| get {return _cookedValue;} | ||
| set {_cookedValue = value;} | ||
| } | ||
| private double _cookedValue = 0; | ||
|
|
||
| public UInt64 RawValue | ||
| { | ||
| get {return _rawValue;} | ||
| set {_rawValue = value;} | ||
| } | ||
| private UInt64 _rawValue = 0; | ||
|
|
||
| public UInt64 SecondValue | ||
| { | ||
| get {return _secondValue;} | ||
| set {_secondValue = value;} | ||
| } | ||
| private UInt64 _secondValue = 0; | ||
|
|
||
| public uint MultipleCount | ||
| { | ||
| get {return _multiCount;} | ||
| set {_multiCount = value;} | ||
| } | ||
| private uint _multiCount = 0; | ||
|
|
||
| public PerformanceCounterType CounterType | ||
| { | ||
| get {return _counterType;} | ||
| set {_counterType = value;} | ||
| } | ||
| private PerformanceCounterType _counterType = 0; | ||
|
|
||
| public DateTime Timestamp | ||
| { | ||
| get {return _timeStamp;} | ||
| set {_timeStamp = value;} | ||
| } | ||
| private DateTime _timeStamp = DateTime.MinValue; | ||
|
|
||
|
|
||
| public UInt64 Timestamp100NSec | ||
| { | ||
| get {return _timeStamp100nSec;} | ||
| set {_timeStamp100nSec = value;} | ||
| } | ||
| private UInt64 _timeStamp100nSec = 0; | ||
|
|
||
| public UInt32 Status | ||
| { | ||
| get {return _status;} | ||
| set {_status = value;} | ||
| } | ||
| private UInt32 _status = 0; | ||
|
|
||
| public UInt32 DefaultScale | ||
| { | ||
| get {return _defaultScale;} | ||
| set {_defaultScale = value;} | ||
| } | ||
| private UInt32 _defaultScale = 0; | ||
|
|
||
| public UInt64 TimeBase | ||
| { | ||
| get {return _timeBase;} | ||
| set {_timeBase = value;} | ||
| } | ||
| private UInt64 _timeBase = 0; | ||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
||
| public class PerformanceCounterSampleSet | ||
| { | ||
| internal PerformanceCounterSampleSet() | ||
| { | ||
| _resourceMgr = new ResourceManager("GetEventResources", Assembly.GetExecutingAssembly()); | ||
| } | ||
|
|
||
| internal PerformanceCounterSampleSet (DateTime timeStamp, | ||
| PerformanceCounterSample[] counterSamples, | ||
| bool firstSet) : this() | ||
| { | ||
| _timeStamp = timeStamp; | ||
| _counterSamples = counterSamples; | ||
| } | ||
|
|
||
| public DateTime Timestamp | ||
| { | ||
| get {return _timeStamp;} | ||
| set {_timeStamp = value;} | ||
| } | ||
| private DateTime _timeStamp = DateTime.MinValue; | ||
|
|
||
| [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", | ||
| Scope = "member", | ||
| Target = "Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample.CounterSamples", | ||
| Justification="A string[] is required here because that is the type Powershell supports")] | ||
| public PerformanceCounterSample[] CounterSamples | ||
| { | ||
| get {return _counterSamples;} | ||
| set {_counterSamples = value;} | ||
| } | ||
| private PerformanceCounterSample[] _counterSamples = null; | ||
|
|
||
| private ResourceManager _resourceMgr = null; | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no AssemblyInfo.cs or AssemblyInfo.cst in SD. sergei (@vors) are we supposed to create such file in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dongbo Wang (@daxian-dbw) yes, in windows build they are generated from templates by build scripts. We need them for FullCLR at least, because we want to deploy assemlbies in GAC and it requires signing. #739 for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sergei (@vors) Dongbo Wang (@daxian-dbw) You bring up a good point, for the assembly info files that are auto-generated... I'm wondering if the updated schema can handle all of this now. Here are the available build options. At least the key file and delayed attribute can be set through this (probably for both frameworks, not just FullCLR). I'm not sure about the version of culture values though. If we still need an assembly info source file, I imagine we could share it among the libraries.