Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Core / System / Diagnostics / Eventing / EventDescriptor.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="etwprovider.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //------------------------------------------------------------------------------
6 using System;
7 using System.Runtime.InteropServices;
8 using System.Diagnostics.CodeAnalysis;
9
10 namespace System.Diagnostics.Eventing
11 {
12     [StructLayout(LayoutKind.Explicit, Size = 16)]
13     [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
14     public struct EventDescriptor
15     {
16         [FieldOffset(0)]
17         private ushort m_id;
18         [FieldOffset(2)]
19         private byte m_version;
20         [FieldOffset(3)]
21         private byte m_channel;
22         [FieldOffset(4)]
23         private byte m_level;
24         [FieldOffset(5)]
25         private byte m_opcode;
26         [FieldOffset(6)]
27         private ushort m_task;
28         [FieldOffset(8)]
29         private long m_keywords;
30
31         [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "opcode", Justification = "Microsoft: Shipped public in 3.5, breaking change to fix now.")]
32         public EventDescriptor(
33                 int id,
34                 byte version,
35                 byte channel,
36                 byte level,
37                 byte opcode,
38                 int task,
39                 long keywords
40                 )
41         {
42             if (id < 0)
43             {
44                 throw new ArgumentOutOfRangeException("id", SR.GetString(SR.ArgumentOutOfRange_NeedNonNegNum));
45             }
46
47             if (id > ushort.MaxValue)
48             {
49                 throw new ArgumentOutOfRangeException("id", SR.GetString(SR.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));
50             }
51
52             m_id = (ushort)id;
53             m_version = version;
54             m_channel = channel;
55             m_level = level;
56             m_opcode = opcode;
57             m_keywords = keywords;
58
59             if (task < 0)
60             {
61                 throw new ArgumentOutOfRangeException("task", SR.GetString(SR.ArgumentOutOfRange_NeedNonNegNum));
62             }
63
64             if (task > ushort.MaxValue)
65             {
66                 throw new ArgumentOutOfRangeException("task", SR.GetString(SR.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));
67             }
68
69             m_task = (ushort)task;
70         }
71
72         public int EventId { 
73             get {
74                 return m_id;
75             }
76         }
77
78         public byte Version
79         {
80             get
81             {
82                 return m_version;
83             }
84         }
85
86         public byte Channel
87         {
88             get
89             {
90                 return m_channel;
91             }
92         }
93         public byte Level
94         {
95             get
96             {
97                 return m_level;
98             }
99         }
100
101         [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Opcode", Justification = "Microsoft: Shipped public in 3.5, breaking change to fix now.")]
102         public byte Opcode
103         {
104             get
105             {
106                 return m_opcode;
107             }
108         }
109
110         public int Task
111         {
112             get
113             {
114                 return m_task;
115             }
116         }
117
118         public long Keywords
119         {
120             get
121             {
122                 return m_keywords;
123             }
124         }
125
126     }
127 }