<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace EnumerableTest.Sdk
{
    /// <summary>
    /// Represents a value returned by a property.
    /// </summary>
    [Serializable]
    public sealed class MarshalResultValue
        : MarshalResult
    {
        /// <summary>
        /// Gets the value.
        /// </summary>
        public MarshalValue MarshalValue { get; }

        internal MarshalResultValue(MarshalValue value)
        {
            MarshalValue = value;
        }
    }

    /// <summary>
    /// Represents an exception thrown by a property.
    /// </summary>
    [Serializable]
    public sealed class MarshalResultException
        : MarshalResult
    {
        /// <summary>
        /// Gets the exception.
        /// </summary>
        public Exception Exception { get; }

        internal MarshalResultException(Exception exception)
        {
            Exception = exception;
        }
    }

    /// <summary>
    /// Represents a marshal value or an exception.
    /// </summary>
    [Serializable]
    public abstract class MarshalResult
    {
        /// <summary>
        /// Determines the runtime type of this and evaluates a function for it.
        /// </summary>
        /// <typeparam name="X"></typeparam>
        /// <param name="onValue"></param>
        /// <param name="onException"></param>
        /// <returns></returns>
        public X Match<X>(Func<MarshalValue, X> onValue, Func<Exception, X> onException)
        {
            var exception = this as MarshalResultException;
            if (exception != null)
            {
                return onException(exception.Exception);
            }
            return onValue(((MarshalResultValue)this).MarshalValue);
        }

        internal static MarshalResult Create(Func<MarshalValue> create)
        {<commit_msg>Implement MarshalValue.Match as an abstract method<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace EnumerableTest.Sdk
{
    /// <summary>
    /// Represents a value returned by a property.
    /// </summary>
    [Serializable]
    public sealed class MarshalResultValue
        : MarshalResult
    {
        /// <summary>
        /// Gets the value.
        /// </summary>
        public MarshalValue MarshalValue { get; }

        /// <summary>
        /// Invokes <paramref name="onValue"/>.
        /// </summary>
        /// <typeparam name="X"></typeparam>
        /// <param name="onValue"></param>
        /// <param name="onException"></param>
        /// <returns></returns>
        public override X Match<X>(Func<MarshalValue, X> onValue, Func<Exception, X> onException)
        {
            return onValue(MarshalValue);
        }

        internal MarshalResultValue(MarshalValue value)
        {
            MarshalValue = value;
        }
    }

    /// <summary>
    /// Represents an exception thrown by a property.
    /// </summary>
    [Serializable]
    public sealed class MarshalResultException
        : MarshalResult
    {
        /// <summary>
        /// Gets the exception.
        /// </summary>
        public Exception Exception { get; }

        /// <summary>
        /// Invokes <paramref name="onException"/>.
        /// </summary>
        /// <typeparam name="X"></typeparam>
        /// <param name="onValue"></param>
        /// <param name="onException"></param>
        /// <returns></returns>
        public override X Match<X>(Func<MarshalValue, X> onValue, Func<Exception, X> onException)
        {
            return onException(Exception);
        }

        internal MarshalResultException(Exception exception)
        {
            Exception = exception;
        }
    }

    /// <summary>
    /// Represents a marshal value or an exception.
    /// </summary>
    [Serializable]
    public abstract class MarshalResult
    {
        /// <summary>
        /// Determines the runtime type of this and evaluates a function for it.
        /// </summary>
        /// <typeparam name="X"></typeparam>
        /// <param name="onValue"></param>
        /// <param name="onException"></param>
        /// <returns></returns>
        public abstract X Match<X>(Func<MarshalValue, X> onValue, Func<Exception, X> onException);

        internal static MarshalResult Create(Func<MarshalValue> create)
        {
{'fraction_non_alphanumeric': 0.12678218907655187, 'fraction_numerical': 0.0, 'mean_word_length': 1.9081632653061225, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '961138', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1151, 'n_words': 308}