Compare commits

...

2 Commits

Author SHA1 Message Date
Yu Leng (from Dev Box)
e2527ed6b3 Add UnconditionalSuppressMessage 2025-04-28 15:52:10 +08:00
Yu Leng (from Dev Box)
746c0d5a48 init 2025-04-28 13:57:07 +08:00
4 changed files with 8 additions and 5 deletions

View File

@@ -18,7 +18,7 @@ namespace Microsoft.PowerToys.Telemetry
/// It is intended to record telemetry events generated by the PowerToys processes so that end users
/// can view them if they want.
/// </summary>
public class ETWTrace : IDisposable
public partial class ETWTrace : IDisposable
{
internal const EventKeywords TelemetryKeyword = (EventKeywords)0x0000200000000000;
internal const EventKeywords MeasuresKeyword = (EventKeywords)0x0000400000000000;
@@ -34,7 +34,7 @@ namespace Microsoft.PowerToys.Telemetry
#nullable enable
private TraceEventSession? traceSession;
internal sealed class Lister : EventListener
internal sealed partial class Lister : EventListener
{
public Lister()
: base()

View File

@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Look at Directory.Build.props in root for common stuff as well -->
<Import Project="..\..\..\Common.Dotnet.CsWinRT.props" />
<Import Project="..\..\..\Common.Dotnet.AotCompatibility.props" />
<PropertyGroup>
<Description>PowerToys Telemetry</Description>

View File

@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry.Events;
@@ -11,7 +12,7 @@ namespace Microsoft.PowerToys.Telemetry
/// <summary>
/// Telemetry helper class for PowerToys.
/// </summary>
public class PowerToysTelemetry : TelemetryBase
public partial class PowerToysTelemetry : TelemetryBase
{
/// <summary>
/// Name for ETW event.
@@ -34,7 +35,8 @@ namespace Microsoft.PowerToys.Telemetry
/// <summary>
/// Publishes ETW event when an action is triggered on
/// </summary>
public void WriteEvent<T>(T telemetryEvent)
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "Ok, fine. Currently all path which would call this function are a certain Type. That's ok when trimming. But if in the future, we still need another generics warpper for it. Please also add DynamicallyAccessedMembers for it.")]
public void WriteEvent<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(T telemetryEvent)
where T : EventBase, IEvent
{
if (DataDiagnosticsSettings.GetEnabledValue())

View File

@@ -26,7 +26,7 @@ namespace Microsoft.PowerToys.Telemetry
/// <summary>
/// Base class for telemetry events.
/// </summary>
public class TelemetryBase : EventSource
public partial class TelemetryBase : EventSource
{
/// <summary>
/// The event tag for this event source.