diff --git a/src/Riok.Mapperly.Abstractions/MapperMaxRecursionDepthAttribute.cs b/src/Riok.Mapperly.Abstractions/MapperMaxRecursionDepthAttribute.cs
index ceb419e9cc..5547d94b7a 100644
--- a/src/Riok.Mapperly.Abstractions/MapperMaxRecursionDepthAttribute.cs
+++ b/src/Riok.Mapperly.Abstractions/MapperMaxRecursionDepthAttribute.cs
@@ -1,9 +1,12 @@
-namespace Riok.Mapperly.Abstractions;
+using System.Diagnostics;
+
+namespace Riok.Mapperly.Abstractions;
///
/// Defines the maximum recursion depth that an IQueryable mapping will use.
///
[AttributeUsage(AttributeTargets.Method)]
+[Conditional("MAPPERLY_ABSTRACTIONS_SCOPE_RUNTIME")]
public sealed class MapperMaxRecursionDepthAttribute : Attribute
{
///
diff --git a/src/Riok.Mapperly/AnalyzerReleases.Shipped.md b/src/Riok.Mapperly/AnalyzerReleases.Shipped.md
index 7c7f01730f..9c57ddeca4 100644
--- a/src/Riok.Mapperly/AnalyzerReleases.Shipped.md
+++ b/src/Riok.Mapperly/AnalyzerReleases.Shipped.md
@@ -131,6 +131,7 @@ RMG055 | Mapper | Error | The source type does not implement ToString with
RMG056 | Mapper | Error | Invalid format provider signature
RMG057 | Mapper | Error | Format provider not found
RMG058 | Mapper | Error | Multiple default format providers found, only one is allowed
+RMG059 | Mapper | Error | The value of MaxRecursionDepth cannot be less than zero
### Removed Rules
Rule ID | Category | Severity | Notes
diff --git a/src/Riok.Mapperly/Diagnostics/DiagnosticDescriptors.cs b/src/Riok.Mapperly/Diagnostics/DiagnosticDescriptors.cs
index dd66298261..580ece5470 100644
--- a/src/Riok.Mapperly/Diagnostics/DiagnosticDescriptors.cs
+++ b/src/Riok.Mapperly/Diagnostics/DiagnosticDescriptors.cs
@@ -511,7 +511,7 @@ public static class DiagnosticDescriptors
);
public static readonly DiagnosticDescriptor MaxRecursionDepthMustBeZeroOrMore = new DiagnosticDescriptor(
- "RMG056",
+ "RMG059",
$"The value of MaxRecursionDepth cannot be less than zero",
$"The value of MaxRecursionDepth cannot be less than zero",
DiagnosticCategories.Mapper,
diff --git a/test/Riok.Mapperly.Tests/_snapshots/QueryableProjectionLoopTest.SetRecursionDepthToTwo#Mapper.g.verified.cs b/test/Riok.Mapperly.Tests/_snapshots/QueryableProjectionLoopTest.SetRecursionDepthToTwo#Mapper.g.verified.cs
index f2f5121794..0a3ee11d1c 100644
--- a/test/Riok.Mapperly.Tests/_snapshots/QueryableProjectionLoopTest.SetRecursionDepthToTwo#Mapper.g.verified.cs
+++ b/test/Riok.Mapperly.Tests/_snapshots/QueryableProjectionLoopTest.SetRecursionDepthToTwo#Mapper.g.verified.cs
@@ -3,6 +3,7 @@
#nullable enable
public partial class Mapper
{
+ [global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "0.0.1.0")]
private partial global::System.Linq.IQueryable Map(global::System.Linq.IQueryable source)
{
#nullable disable