Skip to content

Avoid specialized-generic methods for object null checks in StylusTraceLogger #10880

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//
Expand Down Expand Up @@ -105,8 +105,8 @@ public StylusDeviceInfo(int id, string name, string pnpId, TabletHardwareCapabil
Name = name;
PlugAndPlayId = pnpId;
Capabilities = capabilities.ToString("F");
TabletSize = new StylusTraceLogger.StylusSize(tabletSize);
ScreenSize = new StylusTraceLogger.StylusSize(screenSize);
TabletSize = new StylusSize(tabletSize);
ScreenSize = new StylusSize(screenSize);
DeviceType = deviceType.ToString("F");
MaxContacts = maxContacts;
}
Expand Down Expand Up @@ -202,7 +202,7 @@ internal static void LogStartup()
/// <param name="stylusData">The statistics to log</param>
internal static void LogStatistics(StylusStatistics stylusData)
{
Requires<ArgumentNullException>(stylusData != null);
ArgumentNullException.ThrowIfNull(stylusData);

Log(StatisticsTag, stylusData);
}
Expand All @@ -221,7 +221,7 @@ internal static void LogReentrancyRetryLimitReached()
/// <param name="error"></param>
internal static void LogError(string error)
{
Requires<ArgumentNullException>(error != null);
ArgumentNullException.ThrowIfNull(error);

Log(ErrorTag, new StylusErrorEventData() { Error = error });
}
Expand All @@ -232,7 +232,7 @@ internal static void LogError(string error)
/// <param name="deviceInfo"></param>
internal static void LogDeviceConnect(StylusDeviceInfo deviceInfo)
{
Requires<ArgumentNullException>(deviceInfo != null);
ArgumentNullException.ThrowIfNull(deviceInfo);

Log(DeviceConnectTag, deviceInfo);
}
Expand Down Expand Up @@ -268,19 +268,6 @@ internal static void LogShutdown()

#region Utility

/// <summary>
/// Throws exception when condition is not met. We can't use the contracts version of this
/// since ccrewrite does not work on C++\CLI or netmodules and PresentationCore is a hybrid
/// assembly.
/// </summary>
/// <typeparam name="T">The type of exception to throw</typeparam>
/// <param name="condition">The condition to check</param>
private static void Requires<T>(bool condition)
where T : Exception, new()
{
if (!condition) throw new T();
}

/// <summary>
/// Logs a tag with no associated data
/// </summary>
Expand Down