<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NServiceBus;
using NServiceBus.Configuration.AdvancedExtensibility;

public static class EndpointConfigurationExtensions
{

    public static List<Type> ScannedTypes(this EndpointConfiguration configuration)
    {
        var field = typeof(EndpointConfiguration)
            .GetField("scannedTypes", BindingFlags.Instance | BindingFlags.NonPublic);
        return (List<Type>)field.GetValue(configuration);
    }

    public static bool IsSendOnly(this EndpointConfiguration configuration)
    {
        return configuration.GetSettings().Get<bool>("Endpoint.SendOnly");
    }


    public static IEnumerable<Type> GetScannedSagaTypes(this EndpointConfiguration configuration)
    {
        return configuration.ScannedTypes()
            .Where(type => !type.IsAbstract && typeof(Saga).IsAssignableFrom(type));
    }
}<commit_msg>throw for no field scannedTypes on EndpointConfiguration<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NServiceBus;
using NServiceBus.Configuration.AdvancedExtensibility;

public static class EndpointConfigurationExtensions
{
    public static List<Type> ScannedTypes(this EndpointConfiguration configuration)
    {
        var field = typeof(EndpointConfiguration)
            .GetField("scannedTypes", BindingFlags.Instance | BindingFlags.NonPublic);
        if (field == null)
        {
            throw new Exception("Could not extract field 'scannedTypes' from EndpointConfiguration.");
        }
        return (List<Type>)field.GetValue(configuration);
    }

    public static bool IsSendOnly(this EndpointConfiguration configuration)
    {
        return configuration.GetSettings().Get<bool>("Endpoint.SendOnly");
    }

    public static IEnumerable<Type> GetScannedSagaTypes(this EndpointConfiguration configuration)
    {
        return configuration.ScannedTypes()
            .Where(type => !type.IsAbstract && typeof(Saga).IsAssignableFrom(type));
    }
}
{'fraction_non_alphanumeric': 0.08737397983677389, 'fraction_numerical': 0.0, 'mean_word_length': 4.145679012345679, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '978807', 'n_tokens_mistral': 523, 'n_tokens_neox': 512, 'n_words': 116}