MegaBites-AI/Windows-powershell
0372
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Diagnostics.CodeAnalysis;5using System.Globalization;6using System.Runtime.InteropServices;7 8namespace System.Diagnostics.Eventing9{10 [StructLayout(LayoutKind.Explicit, Size = 16)]11 public readonly struct EventDescriptor12 {13 [FieldOffset(0)]14 private readonly ushort _id;15 16 [FieldOffset(2)]17 private readonly byte _version;18 19 [FieldOffset(3)]20 private readonly byte _channel;21 22 [FieldOffset(4)]23 private readonly byte _level;24 25 [FieldOffset(5)]26 private readonly byte _opcode;27 28 [FieldOffset(6)]29 private readonly ushort _task;30 31 [FieldOffset(8)]32 private readonly long _keywords;33 34 [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "opcode", Justification = "matell: Shipped public in 3.5, breaking change to fix now.")]35 public EventDescriptor(36 int id,37 byte version,38 byte channel,39 byte level,40 byte opcode,41 int task,42 long keywords43 )44 {45 if (id < 0)46 {47 throw new ArgumentOutOfRangeException(nameof(id), DotNetEventingStrings.ArgumentOutOfRange_NeedNonNegNum);48 }49 50 if (id > ushort.MaxValue)51 {52 throw new ArgumentOutOfRangeException(nameof(id), string.Format(CultureInfo.CurrentCulture, DotNetEventingStrings.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));53 }54 55 _id = (ushort)id;56 _version = version;57 _channel = channel;58 _level = level;59 _opcode = opcode;60 _keywords = keywords;61 62 if (task < 0)63 {64 throw new ArgumentOutOfRangeException(nameof(task), DotNetEventingStrings.ArgumentOutOfRange_NeedNonNegNum);65 }66 67 if (task > ushort.MaxValue)68 {69 throw new ArgumentOutOfRangeException(nameof(task), string.Format(CultureInfo.CurrentCulture, DotNetEventingStrings.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));70 }71 72 _task = (ushort)task;73 }74 75 public int EventId76 {77 get78 {79 return _id;80 }81 }82 83 public byte Version84 {85 get86 {87 return _version;88 }89 }90 91 public byte Channel92 {93 get94 {95 return _channel;96 }97 }98 99 public byte Level100 {101 get102 {103 return _level;104 }105 }106 107 [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Opcode", Justification = "matell: Shipped public in 3.5, breaking change to fix now.")]108 public byte Opcode109 {110 get111 {112 return _opcode;113 }114 }115 116 public int Task117 {118 get119 {120 return _task;121 }122 }123 124 public long Keywords125 {126 get127 {128 return _keywords;129 }130 }131 }132}133 