<commit_before>﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Configuration.Internal;
using System.IO;
using Xunit;

namespace System.ConfigurationTests
{
    public class TypeUtilTests
    {
        [Theory
            // CoreLib
            InlineData("System.String", typeof(string))
            InlineData("System.Int32", typeof(int))
            // System.Configuration
            InlineData("System.Configuration.PropertyInformation", typeof(PropertyInformation))
            // System.Runtime, previously System
            InlineData("System.Uri", typeof(Uri))
            // System.Collections, previously System
            InlineData("System.Collections.Generic.LinkedList`1", typeof(LinkedList<>))
            InlineData("System.Collections.Generic.Queue`1", typeof(Queue<>))
            InlineData("System.Collections.Generic.Stack`1", typeof(Stack<>))
            // System.Collections.Concurrent, previously System
            InlineData("System.Collections.Concurrent.ConcurrentBag`1", typeof(ConcurrentBag<>))
            InlineData("System.Collections.Concurrent.BlockingCollection`1", typeof(BlockingCollection<>))
            // System.Collections.Specialized, previously System
            InlineData("System.Collections.Specialized.HybridDictionary", typeof(HybridDictionary))
            InlineData("System.Collections.Specialized.ListDictionary", typeof(ListDictionary))
            InlineData("System.Collections.Specialized.StringDictionary", typeof(StringDictionary))
            InlineData("System.Collections.Specialized.OrderedDictionary", typeof(OrderedDictionary))
            InlineData("System.Collections.Specialized.StringCollection", typeof(StringCollection))
            InlineData("System.Collections.Specialized.NameValueCollection", typeof(NameValueCollection))
            ]
        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19340")]
        public void GetType_NoAssemblyQualifcation(string typeString, Type expectedType)
        {
            Assert.Equal(expectedType, TypeUtil.GetType(typeString, throwOnError: false));
        }

        [Fact]
        public void GetType_ThrowOnError()
        {
            Assert.Throws<TypeLoadException>(() => TypeUtil.GetType("Mxyzptlk", throwOnError: true));
        }

        [Fact]
        public void GetType_NoThrowOnError()
        {
            Assert.Null(TypeUtil.GetType("Mxyzptlk", throwOnError: false));
        }

        [Fact]
        public void GetTypeConfigHost()
        {
            TestHost host = new TestHost((s, b) => { return typeof(string); });
            Assert.Equal(typeof(string), TypeUtil.GetType(host, "Mxyzptlk", throwOnError: false));
        }

        [Fact]
        public void GetTypeConfigHost_ThrowOnError()
        {
            TestHost host = new TestHost((s, b) => { if (b) throw new ArgumentException(); return null; });
            Assert.Throws<ArgumentException>(() => TypeUtil.GetType(host, "Mxyzptlk", throwOnError: true));
        }

        [Fact]
        public void GetTypeConfigHost_NoThrowOnError()<commit_msg>Disable failed tests for issue 19339. (#19393)<commit_after>﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Configuration.Internal;
using System.IO;
using Xunit;

namespace System.ConfigurationTests
{
    public class TypeUtilTests
    {
        [Theory
            // CoreLib
            InlineData("System.String", typeof(string))
            InlineData("System.Int32", typeof(int))
            // System.Configuration
            InlineData("System.Configuration.PropertyInformation", typeof(PropertyInformation))
            // System.Runtime, previously System
            InlineData("System.Uri", typeof(Uri))
            // System.Collections, previously System
            InlineData("System.Collections.Generic.LinkedList`1", typeof(LinkedList<>))
            InlineData("System.Collections.Generic.Queue`1", typeof(Queue<>))
            InlineData("System.Collections.Generic.Stack`1", typeof(Stack<>))
            // System.Collections.Concurrent, previously System
            InlineData("System.Collections.Concurrent.ConcurrentBag`1", typeof(ConcurrentBag<>))
            InlineData("System.Collections.Concurrent.BlockingCollection`1", typeof(BlockingCollection<>))
            // System.Collections.Specialized, previously System
            InlineData("System.Collections.Specialized.HybridDictionary", typeof(HybridDictionary))
            InlineData("System.Collections.Specialized.ListDictionary", typeof(ListDictionary))
            InlineData("System.Collections.Specialized.StringDictionary", typeof(StringDictionary))
            InlineData("System.Collections.Specialized.OrderedDictionary", typeof(OrderedDictionary))
            InlineData("System.Collections.Specialized.StringCollection", typeof(StringCollection))
            InlineData("System.Collections.Specialized.NameValueCollection", typeof(NameValueCollection))
            ]
        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19340")]
        public void GetType_NoAssemblyQualifcation(string typeString, Type expectedType)
        {
            Assert.Equal(expectedType, TypeUtil.GetType(typeString, throwOnError: false));
        }

        [Fact]
        public void GetType_ThrowOnError()
        {
            Assert.Throws<TypeLoadException>(() => TypeUtil.GetType("Mxyzptlk", throwOnError: true));
        }

        [Fact]
        public void GetType_NoThrowOnError()
        {
            Assert.Null(TypeUtil.GetType("Mxyzptlk", throwOnError: false));
        }

        [Fact]
        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19339")]
        public void GetTypeConfigHost()
        {
            TestHost host = new TestHost((s, b) => { return typeof(string); });
            Assert.Equal(typeof(string), TypeUtil.GetType(host, "Mxyzptlk", throwOnError: false));
        }

        [Fact]
        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19339")]
        public void GetTypeConfigHost_ThrowOnError()
        {
            TestHost host = new TestHost((s, b) => { if (b) throw new ArgumentException(); return null; });
            Assert.Throws<ArgumentException>(() => TypeUtil.GetType(host, "Mxyzptlk", throwOnError: true));
        }

        [Fact]
        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19339")]
        public void GetTypeConfigHost_NoThrowOnError()
{'fraction_non_alphanumeric': 0.10681658468025299, 'fraction_numerical': 0.006886858749121574, 'mean_word_length': 3.1444379732090857, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, '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': '3114527', 'n_tokens_mistral': 1838, 'n_tokens_neox': 1776, 'n_words': 348}