From eb4b027266749c43bd6b1c14efcf47387dc588f9 Mon Sep 17 00:00:00 2001 From: Youssef Fahmy Date: Fri, 1 May 2026 10:55:39 +0200 Subject: [PATCH 1/2] Fix nullability annotation of InnerMock --- src/Moq/ISetup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Moq/ISetup.cs b/src/Moq/ISetup.cs index 03255edba..1e493760c 100644 --- a/src/Moq/ISetup.cs +++ b/src/Moq/ISetup.cs @@ -49,7 +49,7 @@ public interface ISetup // /// The setup has more than one inner mock. // [Obsolete("Use 'InnerMocks' instead.")] // [EditorBrowsable(EditorBrowsableState.Never)] - Mock InnerMock { get; } + Mock? InnerMock { get; } // /// // /// Gets the inner mocks of this setup (if present and known). From d551240b1293a268dbbcfd9c6094c80a3d0df224 Mon Sep 17 00:00:00 2001 From: Youssef Fahmy Date: Fri, 1 May 2026 10:56:11 +0200 Subject: [PATCH 2/2] Fix in concrete impl --- src/Moq/Setup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Moq/Setup.cs b/src/Moq/Setup.cs index be6f754db..f9030b851 100644 --- a/src/Moq/Setup.cs +++ b/src/Moq/Setup.cs @@ -35,7 +35,7 @@ protected Setup(Expression originalExpression, Mock mock, Expectation expectatio public LambdaExpression Expression => this.expectation.Expression; - Mock ISetup.InnerMock => this.InnerMocks.SingleOrDefault(); + Mock? ISetup.InnerMock => this.InnerMocks.SingleOrDefault(); public virtual IEnumerable InnerMocks => Enumerable.Empty();