diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2f8e06b44..af544a8654 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
- The User.IpAddress is now set to {{auto}} by default, even when sendDefaultPII is disabled ([#2981](https://github.com/getsentry/sentry-dotnet/pull/2981))
- The "Prevent Storing of IP Addresses" option in the "Security & Privacy" project settings on sentry.io can be used to control this instead
+- The `DiagnosticLogger` signature for `LogWarning` changed to take the `exception` as the first parameter. That way it does no longer get mixed up with the TArgs. ([#2987](https://github.com/getsentry/sentry-dotnet/pull/2987))
### Dependencies
diff --git a/src/Sentry/Extensibility/DiagnosticLoggerExtensions.cs b/src/Sentry/Extensibility/DiagnosticLoggerExtensions.cs
index a0862dc122..ecb2fd4295 100644
--- a/src/Sentry/Extensibility/DiagnosticLoggerExtensions.cs
+++ b/src/Sentry/Extensibility/DiagnosticLoggerExtensions.cs
@@ -166,8 +166,24 @@ public static class DiagnosticLoggerExtensions
///
public static void LogWarning(
this IDiagnosticLogger logger,
- string message,
- Exception? exception = null)
+ string message)
+ => logger.LogIfEnabled(SentryLevel.Warning, null, message);
+
+ ///
+ /// Log a warning message.
+ ///
+ internal static void LogWarning(
+ this SentryOptions options,
+ string message)
+ => options.DiagnosticLogger?.LogIfEnabled(SentryLevel.Warning, null, message);
+
+ ///
+ /// Log a warning message.
+ ///
+ public static void LogWarning(
+ this IDiagnosticLogger logger,
+ Exception exception,
+ string message)
=> logger.LogIfEnabled(SentryLevel.Warning, exception, message);
///
@@ -175,8 +191,8 @@ public static class DiagnosticLoggerExtensions
///
internal static void LogWarning(
this SentryOptions options,
- string message,
- Exception? exception = null)
+ Exception exception,
+ string message)
=> options.DiagnosticLogger?.LogIfEnabled(SentryLevel.Warning, exception, message);
///
diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
index 08da5368cb..1014e7160b 100644
--- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
+++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
@@ -1174,7 +1174,8 @@ namespace Sentry.Extensibility
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
- public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
+ public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
+ public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
}
diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
index 08da5368cb..1014e7160b 100644
--- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
+++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
@@ -1174,7 +1174,8 @@ namespace Sentry.Extensibility
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
- public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
+ public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
+ public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
}
diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
index 80b49d47c0..0cf19f3b6c 100644
--- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
+++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
@@ -1175,7 +1175,8 @@ namespace Sentry.Extensibility
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
- public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
+ public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
+ public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
}
diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
index 275680f205..26718ef234 100644
--- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
+++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
@@ -1171,7 +1171,8 @@ namespace Sentry.Extensibility
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
public static void LogInfo(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
- public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
+ public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
+ public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
}