Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp5.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,17 @@ public static class Tasks
//<Snippet5>
[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
public void Failure(string message) { WriteEvent(1, message); }
//</Snippet5>

//<Snippet6>
[Event(2, Message = "Starting up.", Keywords = Keywords.Perf, Level = EventLevel.Informational)]
public void Startup() { WriteEvent(2); }
//</Snippet6>

//<Snippet7>
[Event(3, Message = "loading page {1} activityID={0}", Opcode = EventOpcode.Start,
Task = Tasks.Page, Keywords = Keywords.Page, Level = EventLevel.Informational)]
public void PageStart(int ID, string url) { if (IsEnabled()) WriteEvent(3, ID, url); }
//</Snippet7>

//<Snippet8>

[Event(4, Opcode = EventOpcode.Stop, Task = Tasks.Page, Keywords = Keywords.Page, Level = EventLevel.Informational)]
public void PageStop(int ID) { if (IsEnabled()) WriteEvent(4, ID); }
//</Snippet8>
//</Snippet5>

//<Snippet9>
[Event(5, Opcode = EventOpcode.Start, Task = Tasks.DBQuery, Keywords = Keywords.DataBase, Level = EventLevel.Informational)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Enum MyColor
Red
Yellow
Blue
End Enum 'MyColor
End Enum 'MyColor
<EventSource(Name:="MyCompany")> _
Class MyCompanyEventSource
Inherits EventSource
Expand Down Expand Up @@ -34,32 +34,26 @@ Class MyCompanyEventSource
Public Sub Failure(ByVal message As String)
WriteEvent(1, message)
End Sub
'</Snippet5>

'<Snippet6>
<[Event](2, Message:="Starting up.", Keywords:=Keywords.Perf, Level:=EventLevel.Informational)> _
Public Sub Startup()
WriteEvent(2)
End Sub
'</Snippet6>

'<Snippet7>
<[Event](3, Message:="loading page {1} activityID={0}", Opcode:=EventOpcode.Start, Task:=Tasks.Page, Keywords:=Keywords.Page, Level:=EventLevel.Informational)> _
Public Sub PageStart(ByVal ID As Integer, ByVal url As String)
If IsEnabled() Then
WriteEvent(3, ID, url)
End If
End Sub
'</Snippet7>

'<Snippet8>
<[Event](4, Opcode:=EventOpcode.Stop, Task:=Tasks.Page, Keywords:=Keywords.Page, Level:=EventLevel.Informational)> _
Public Sub PageStop(ByVal ID As Integer)
If IsEnabled() Then
WriteEvent(4, ID)
End If
End Sub
'</Snippet8>
'</Snippet5>

'<Snippet9>
<[Event](5, Opcode:=EventOpcode.Start, Task:=Tasks.DBQuery, Keywords:=Keywords.DataBase, Level:=EventLevel.Informational)> _
Expand Down Expand Up @@ -117,4 +111,4 @@ Class Program
'</Snippet13>
End Sub
End Class
'</Snippet1>
'</Snippet1>
185 changes: 74 additions & 111 deletions xml/System.Diagnostics.Tracing/EventAttribute.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,17 @@
<Docs>
<summary>Specifies additional event schema information for an event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When you apply this attribute to an ETW event method defined on an <xref:System.Diagnostics.Tracing.EventSource>-derived class, you must call the <xref:System.Diagnostics.Tracing.EventSource.WriteEvent%2A> method on the base class, passing the event ID, followed by the same arguments as the defined method is passed. You should follow the pattern shown in the following examples.
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute> class to define a variety of events. This code example is part of a larger example provided for the <xref:System.Diagnostics.Tracing.EventSource> class.
<format type="text/markdown"><![CDATA[
When you apply this attribute to an ETW event method defined on an <xref:System.Diagnostics.Tracing.EventSource>-derived class, you must call the <xref:System.Diagnostics.Tracing.EventSource.WriteEvent%2A> method on the base class, passing the event ID, followed by the same arguments as the defined method is passed. Follow the pattern shown in the examples.
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute> class to define a variety of events. This code example is part of a larger example provided for the [EventSource](/dotnet/fundamentals/runtime-libraries/system-diagnostics-tracing-eventsource#examples) class.
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet5":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet6":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet7":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet7":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet8":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet8":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet5":::
]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -126,17 +115,17 @@
<param name="eventId">The event identifier for the event.</param>
<summary>Initializes a new instance of the <see cref="T:System.Diagnostics.Tracing.EventAttribute" /> class with the specified event identifier.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.%23ctor%2A> constructor to specify events. This code example is part of a larger example provided for the <xref:System.Diagnostics.Tracing.EventSource> class.
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.%23ctor%2A> constructor to specify events. This code example is part of a larger example provided for the [EventSource](/dotnet/fundamentals/runtime-libraries/system-diagnostics-tracing-eventsource#examples) class.
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet2":::
]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -264,11 +253,10 @@
<summary>Gets or sets the identifier for the event.</summary>
<value>The event identifier. This value should be between 0 and 65535.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Diagnostics.Tracing.EventAttribute.EventId%2A> should be greater than 0 or less than 65535 or errors can occur in a tracing operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.
<format type="text/markdown"><![CDATA[
<xref:System.Diagnostics.Tracing.EventAttribute.EventId%2A> should be greater than 0 or less than 65535 or errors can occur in a tracing operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.
]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -314,23 +302,17 @@
<summary>Gets or sets the keywords for the event.</summary>
<value>A bitwise combination of the enumeration values.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Keywords%2A> property to define event keywords. This code example is part of a larger example provided for the <xref:System.Diagnostics.Tracing.EventSource> class.
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Keywords%2A> property to define event keywords. This code example is part of a larger example provided for the [EventSource](/dotnet/fundamentals/runtime-libraries/system-diagnostics-tracing-eventsource#examples) class.
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet3":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet5":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet6":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet7":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet7":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet5":::
]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -376,20 +358,14 @@
<summary>Gets or sets the level for the event.</summary>
<value>One of the enumeration values that specifies the level for the event.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Level%2A> property to specify event levels. This code example is part of a larger example provided for the <xref:System.Diagnostics.Tracing.EventSource> class.
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Level%2A> property to specify event levels. This code example is part of a larger example provided for the [EventSource](/dotnet/fundamentals/runtime-libraries/system-diagnostics-tracing-eventsource#examples) class.
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet5":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet6":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet11":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet11":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet5":::
]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -436,31 +412,22 @@
<summary>Gets or sets the message for the event.</summary>
<value>The message for the event.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can use standard .NET Framework substitution operators (for example, {1}) in the string). They will be replaced with the string representation of the corresponding part of the event payload.
```csharp
[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
        public void Failure(string message) { WriteEvent(1, message); }
```
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Message%2A> property to specify event messages. This code example is part of a larger example provided for the <xref:System.Diagnostics.Tracing.EventSource> class.
<format type="text/markdown"><![CDATA[
You can use standard .NET substitution operators (for example, {1}) in the string). They will be replaced with the string representation of the corresponding part of the event payload.
```csharp
[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
public void Failure(string message) { WriteEvent(1, message); }
```
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Message%2A> property to specify event messages. This code example is part of a larger example provided for the [EventSource](/dotnet/fundamentals/runtime-libraries/system-diagnostics-tracing-eventsource#examples) class.
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet5":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet6":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet6":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet7":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet7":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet5":::
]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -506,20 +473,18 @@
<summary>Gets or sets the operation code for the event.</summary>
<value>One of the enumeration values that specifies the operation code.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Opcode%2A> property to specify operation codes. This code example is part of a larger example provided for the <xref:System.Diagnostics.Tracing.EventSource> class.
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet8":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet8":::
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Opcode%2A> property to specify operation codes. This code example is part of a larger example provided for the [EventSource](/dotnet/fundamentals/runtime-libraries/system-diagnostics-tracing-eventsource#examples) class.
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet9":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet9":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet9":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet10":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet10":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet10":::
]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -606,20 +571,18 @@
<summary>Gets or sets the task for the event.</summary>
<value>The task for the event.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Task%2A> property to define event tasks. This code example is part of a larger example provided for the <xref:System.Diagnostics.Tracing.EventSource> class.
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to use the <xref:System.Diagnostics.Tracing.EventAttribute.Task%2A> property to define event tasks. This code example is part of a larger example provided for the [EventSource](/dotnet/fundamentals/runtime-libraries/system-diagnostics-tracing-eventsource#examples) class.
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet4":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet4":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet8":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet8":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet4":::
:::code language="csharp" source="~/snippets/csharp/System.Diagnostics.Tracing/EventAttribute/Overview/program.cs" id="Snippet9":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet9":::
:::code language="vb" source="~/snippets/visualbasic/System.Diagnostics.Tracing/EventAttribute/Overview/program.vb" id="Snippet9":::
]]></format>
</remarks>
</Docs>
Expand Down
Loading