Skip to content

Should we make MultipleAssertException.TestResult maybe-null or obsolete two constructors? #3485

Description

@jnm2

@nunit/framework-team

Option 1

namespace NUnit.Framework
{
    public class MultipleAssertException : ResultStateException
    {
        // Throws if testResult is null
        public MultipleAssertException(ITestResult testResult);
        
        // Leaves TestResult null
        public MultipleAssertException(string? message);
        
        // Leaves TestResult null
        public MultipleAssertException(string? message, Exception? inner);

        protected MultipleAssertException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);

        public override ResultState ResultState { get; }

        // Maybe null
        public ITestResult? TestResult { get; }
    }
}

Option 2

namespace NUnit.Framework
{
    public class MultipleAssertException : ResultStateException
    {
        // Throws if testResult is null
        public MultipleAssertException(ITestResult testResult);
        
        // Leaves TestResult null
+       [Obsolete("The MultipleAssertException(ITestResult) constructor must be used.")]
        public MultipleAssertException(string? message);
        
        // Leaves TestResult null
+       [Obsolete("The MultipleAssertException(ITestResult) constructor must be used.")]
        public MultipleAssertException(string? message, Exception? inner);

        protected MultipleAssertException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);

        public override ResultState ResultState { get; }

-       // Maybe null
-       public ITestResult? TestResult { get; }
+       // Not null
+       public ITestResult TestResult { get; }
    }
}

master...jnm2:annotate_exceptions

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions