7 instantiations of TypeName
System.Reflection.Metadata (7)
System\Reflection\Metadata\TypeName.cs (3)
608return new TypeName(fullName: _fullName, 673return new TypeName(fullName: null, AssemblyName, elementOrGenericType: this, declaringType: _declaringType, genericTypeArguments: typeArguments); 677=> new TypeName(
System\Reflection\Metadata\TypeNameParser.cs (4)
207TypeName result = new(fullName, assemblyName, declaringType: declaringType); 210result = new(fullName: null, assemblyName, elementOrGenericType: result, declaringType, genericArgs); 220result = new(fullName: null, assemblyName, elementOrGenericType: result, rankOrModifier: parsedModifier); 267declaringType = new(fullTypeName, assemblyName, declaringType: declaringType, nestedNameLength: fullNameLength);
440 references to TypeName
illink (12)
Microsoft.VisualBasic.Forms (2)
Microsoft\VisualBasic\MyServices\ClipboardProxy.vb (2)
196''' <inheritdoc cref="Clipboard.TryGetData(Of T)(String, Func(Of TypeName, Type), ByRef T)" /> 197Public Function TryGetData(Of T)(format As String, resolver As Func(Of TypeName, Type), <Out> ByRef data As T) As Boolean
Microsoft.VisualBasic.Tests (1)
Microsoft\VisualBasic\MyServices\ClipboardProxyTests.cs (1)
154public static Type Resolver(TypeName typeName) =>
System.Formats.Nrbf (61)
System\Formats\Nrbf\ArrayRectangularPrimitiveRecord.cs (2)
22private TypeName? _typeName; 35public override TypeName TypeName
System\Formats\Nrbf\ArraySingleObjectRecord.cs (1)
24public override TypeName TypeName
System\Formats\Nrbf\ArraySinglePrimitiveRecord.cs (1)
36public override TypeName TypeName => TypeNameHelpers.GetPrimitiveSZArrayTypeName(TypeNameHelpers.GetPrimitiveType<T>());
System\Formats\Nrbf\ArraySingleStringRecord.cs (1)
25public override TypeName TypeName => TypeNameHelpers.GetPrimitiveSZArrayTypeName(TypeNameHelpers.StringPrimitiveType);
System\Formats\Nrbf\BinaryLibraryRecord.cs (2)
33public override TypeName TypeName => TypeName.Parse(nameof(BinaryLibraryRecord).AsSpan());
System\Formats\Nrbf\ClassInfo.cs (2)
23private TypeName? _typeName; 34internal TypeName TypeName
System\Formats\Nrbf\ClassRecord.cs (1)
23public override TypeName TypeName => ClassInfo.TypeName;
System\Formats\Nrbf\ClassTypeInfo.cs (2)
20internal ClassTypeInfo(TypeName typeName) => TypeName = typeName; 22internal TypeName TypeName { get; }
System\Formats\Nrbf\JaggedArrayRecord.cs (2)
26private TypeName? _typeName; 43public override TypeName TypeName => _typeName ??= _memberTypeInfo.GetArrayTypeName(ArrayInfo);
System\Formats\Nrbf\MemberReferenceRecord.cs (1)
34public override TypeName TypeName => GetReferencedRecord().TypeName;
System\Formats\Nrbf\MemberTypeInfo.cs (3)
111internal TypeName GetArrayTypeName(ArrayInfo arrayInfo) 115TypeName elementTypeName = binaryType switch 123BinaryType.SystemClass => (TypeName)additionalInfo!,
System\Formats\Nrbf\MessageEndRecord.cs (2)
27public override TypeName TypeName => TypeName.Parse(nameof(MessageEndRecord).AsSpan());
System\Formats\Nrbf\NrbfDecoder.cs (5)
402TypeName typeName = binaryType == BinaryType.SystemClass ? (TypeName)additionalInfo! : ((ClassTypeInfo)additionalInfo!).TypeName; 418TypeName typeName = binaryType == BinaryType.SystemClass ? (TypeName)additionalInfo! : ((ClassTypeInfo)additionalInfo!).TypeName; 452else if (binaryType == BinaryType.SystemClass && ((TypeName)additionalInfo!).IsArray)
System\Formats\Nrbf\NullsRecord.cs (2)
15public override TypeName TypeName => TypeName.Parse(GetType().Name.AsSpan());
System\Formats\Nrbf\PayloadOptions.cs (1)
19/// Gets or sets configuration options for parsing <see cref="TypeName"/> instances.
System\Formats\Nrbf\PrimitiveTypeRecordOfT.cs (1)
37public override TypeName TypeName => TypeNameHelpers.GetPrimitiveTypeName(TypeNameHelpers.GetPrimitiveType<T>());
System\Formats\Nrbf\RectangularArrayRecord.cs (2)
23private TypeName? _typeName; 41public override TypeName TypeName
System\Formats\Nrbf\SerializationRecord.cs (3)
46public abstract TypeName TypeName { get; } 72private static bool Matches(Type type, TypeName typeName) 132ImmutableArray<TypeName> genericNames = typeName.GetGenericArguments();
System\Formats\Nrbf\SerializedStreamHeaderRecord.cs (2)
27public override TypeName TypeName => TypeName.Parse(nameof(SerializedStreamHeaderRecord).AsSpan());
System\Formats\Nrbf\SystemClassWithMembersAndTypesRecord.cs (1)
31TypeName typeName = classInfo.TypeName;
System\Formats\Nrbf\SZArrayOfRecords.cs (2)
17private TypeName? _typeName; 32public override TypeName TypeName
System\Formats\Nrbf\Utils\TypeNameHelpers.cs (22)
20private static readonly TypeName?[] s_primitiveTypeNames = new TypeName?[(int)UIntPtrPrimitiveType + 1]; 21private static readonly TypeName?[] s_primitiveSZArrayTypeNames = new TypeName?[(int)UIntPtrPrimitiveType + 1]; 24internal static TypeName GetPrimitiveTypeName(PrimitiveType primitiveType) 26TypeName? typeName = s_primitiveTypeNames[(int)primitiveType]; 53s_primitiveTypeNames[(int)primitiveType] = typeName = TypeName.Parse(fullName.AsSpan()).WithCoreLibAssemblyName(); 58internal static TypeName GetPrimitiveSZArrayTypeName(PrimitiveType primitiveType) 60TypeName? typeName = s_primitiveSZArrayTypeNames[(int)primitiveType]; 110internal static TypeName ParseNonSystemClassRecordTypeName(this string rawName, BinaryLibraryRecord libraryRecord, PayloadOptions payloadOptions) 133TypeName.TryParse(assemblyQualifiedName.AsSpan(), out TypeName? typeName, payloadOptions.TypeNameParseOptions); 153internal static TypeName ParseSystemRecordTypeName(this string rawName, PayloadOptions payloadOptions) 157internal static TypeName WithCoreLibAssemblyName(this TypeName systemType) 160private static TypeName With(this TypeName typeName, AssemblyNameInfo assemblyName) 170TypeName newElementType = typeName.GetElementType().With(assemblyName); 178TypeName newGenericTypeDefinition = typeName.GetGenericTypeDefinition().With(assemblyName); 193private static TypeName ParseWithoutAssemblyName(string rawName, PayloadOptions payloadOptions) 195if (!TypeName.TryParse(rawName.AsSpan(), out TypeName? typeName, payloadOptions.TypeNameParseOptions)
System.Private.Windows.Core (72)
System\Private\Windows\BinaryFormat\Deserializer\DefaultTypeResolver.cs (3)
24Type ITypeResolver.BindToType(TypeName typeName) 34public bool TryBindToType(TypeName typeName, [NotNullWhen(true)] out Type? type) 90private static Type? GetSimplyNamedTypeFromAssembly(Assembly assembly, TypeName typeName)
System\Private\Windows\BinaryFormat\ITypeResolver.cs (2)
16Type BindToType(TypeName typeName); 21bool TryBindToType(TypeName typeName, [NotNullWhen(true)] out Type? type);
System\Private\Windows\Nrbf\CoreNrbfSerializer.cs (21)
17private static Dictionary<TypeName, Type>? s_knownTypes; 29public static bool TryBindToType(TypeName typeName, [NotNullWhen(true)] out Type? type) 36{ TypeName.Parse(Types.ByteType), typeof(byte) }, 37{ TypeName.Parse(Types.SByteType), typeof(sbyte) }, 38{ TypeName.Parse(Types.Int16Type), typeof(short) }, 39{ TypeName.Parse(Types.UInt16Type), typeof(ushort) }, 40{ TypeName.Parse(Types.Int32Type), typeof(int) }, 41{ TypeName.Parse(Types.UInt32Type), typeof(uint) }, 42{ TypeName.Parse(Types.Int64Type), typeof(long) }, 43{ TypeName.Parse(Types.UInt64Type), typeof(ulong) }, 44{ TypeName.Parse(Types.DoubleType), typeof(double) }, 45{ TypeName.Parse(Types.SingleType), typeof(float) }, 46{ TypeName.Parse(Types.CharType), typeof(char) }, 47{ TypeName.Parse(Types.BooleanType), typeof(bool) }, 48{ TypeName.Parse(Types.StringType), typeof(string) }, 49{ TypeName.Parse(Types.DecimalType), typeof(decimal) }, 50{ TypeName.Parse(Types.DateTimeType), typeof(DateTime) }, 51{ TypeName.Parse(Types.TimeSpanType), typeof(TimeSpan) }, 52{ TypeName.Parse(Types.IntPtrType), typeof(IntPtr) }, 53{ TypeName.Parse(Types.UIntPtrType), typeof(UIntPtr) }, 54{ TypeName.Parse(Types.NotSupportedExceptionType), typeof(NotSupportedException) },
System\Private\Windows\Nrbf\INrbfSerializer.cs (2)
25static abstract bool TryBindToType(TypeName typeName, [NotNullWhen(true)] out Type? type); 38/// <see cref="TryBindToType(TypeName, out Type?)"/> and <see cref="TryGetObject(SerializationRecord, out object?)"/>
System\Private\Windows\Nrbf\SerializationRecordExtensions.cs (2)
604|| !TypeName.TryParse(assemblyQualifiedTypeName, out TypeName? typeName))
System\Private\Windows\Ole\Composition.cs (1)
159Func<TypeName, Type?> resolver,
System\Private\Windows\Ole\Composition.NativeToManagedAdapter.cs (1)
591Func<TypeName, Type?> resolver,
System\Private\Windows\Ole\DataRequest.cs (2)
28/// <see cref="TypeName"/>s read from the deserialized stream. 30public Func<TypeName, Type?>? Resolver { get; init; } = null;
System\Private\Windows\Ole\DataStore.cs (1)
178Func<TypeName, Type?> resolver,
System\Private\Windows\Ole\IDataObjectInternal.cs (5)
96/// <inheritdoc cref="TryGetData{T}(string, Func{TypeName, Type}, bool, out T)"/> 103/// <inheritdoc cref="TryGetData{T}(string, Func{TypeName, Type}, bool, out T)"/> 112/// <inheritdoc cref="TryGetData{T}(string, Func{TypeName, Type}, bool, out T)"/> 122/// A user-provided function that maps <see cref="TypeName"/> to <see cref="Type"/>. 151Func<TypeName, Type?> resolver,
System\Private\Windows\Ole\TypeBinder.cs (6)
35private readonly Func<TypeName, Type?>? _resolver; 38private Dictionary<FullyQualifiedTypeName, TypeName>? _cachedTypeNames; 79if (!_cachedTypeNames.TryGetValue(fullName, out TypeName? parsed)) 81parsed = TypeName.Parse(fullName.ToString()); 88public Type BindToType(TypeName typeName) => TryBindToType(typeName, out Type? type) 94public bool TryBindToType(TypeName typeName, [NotNullWhen(true)] out Type? type)
System\Reflection\Metadata\TypeNameComparer.cs (6)
7/// Compares <see cref="TypeName"/>s. 9internal sealed class TypeNameComparer : IEqualityComparer<TypeName> 32public bool Equals(TypeName? x, TypeName? y) 47public int GetHashCode(TypeName obj) 63foreach (TypeName genericName in obj.GetGenericArguments())
System\TypeExtensions.cs (16)
12/// Helper methods for comparing <see cref="Type"/>s and <see cref="TypeName"/>s. 24TypeName typeName, 71ImmutableArray<TypeName> genericNames = typeName.GetGenericArguments(); 96/// <inheritdoc cref="Matches(Type, TypeName, TypeNameComparison)"/> 97internal static bool Matches(this TypeName x, TypeName y, TypeNameComparison comparison = TypeNameComparison.All) 131ImmutableArray<TypeName> genericNamesY = y.GetGenericArguments(); 132ImmutableArray<TypeName> genericNamesX = x.GetGenericArguments(); 218/// Convert <paramref name="type"/> to <see cref="TypeName"/>. Take into account type forwarding in order 219/// to create <see cref="TypeName"/> compatible with the type names serialized to the binary format.This 220/// method removes nullability wrapper from the top level type only because <see cref="TypeName"/> in the 223internal static TypeName ToTypeName(this Type type) 227return TypeName.Parse(type.AssemblyQualifiedName ?? type.FullName); 239/// Helper method that allows non-allocating conversion of a interpolated string to a <see cref="TypeName"/>. 241internal static TypeName ToTypeName(ref ValueStringBuilder builder) 245return TypeName.Parse(builder.AsSpan());
System\Types.cs (4)
49/// <inheritdoc cref="TypeName.Parse(ReadOnlySpan{char}, TypeNameParseOptions?)"/> 53/// <see cref="TypeName.Parse(ReadOnlySpan{char}, TypeNameParseOptions?)"/> 56public static TypeName ToTypeName(ref ValueStringBuilder builder) 60return TypeName.Parse(builder.AsSpan());
System.Private.Windows.Core.Tests (177)
System\Private\Windows\Nrbf\CoreNrbfSerializerTests.cs (2)
79TypeName typeName = TypeName.Parse(typeNameString);
System\Private\Windows\Ole\BinaryFormatUtilitesTestsBase.cs (6)
46Func<TypeName, Type>? resolver, 64protected bool ReadObjectFromStream<T>(bool restrictDeserialization, Func<TypeName, Type>? resolver, out T? @object) 76protected bool TryReadObjectFromStream<T>(Func<TypeName, Type>? resolver, out T? @object) 82protected bool ReadPredefinedObjectFromStream<T>(Func<TypeName, Type>? resolver, out T? @object) 119protected bool RoundTripOfType<T>(object value, Func<TypeName, Type>? resolver, out T? @object) 127protected static Type NotSupportedResolver(TypeName typeName) =>
System\Private\Windows\Ole\BinaryFormatUtilitiesTests.cs (16)
23Func<TypeName, Type>? resolver, 241Resolver = (TypeName typeName) => Type.GetType(typeName.FullName) 299Resolver = (TypeName typeName) => typeof(int[]).Matches(typeName, TypeNameComparison.TypeFullName) 429static Type ObjectListResolver(TypeName typeName) 493Resolver = (TypeName typeName) => typeName.FullName == typeof(DerivedClass).FullName 532Resolver = (TypeName typeName) => typeName.FullName == typeof(MyStruct).FullName 581Resolver = (TypeName typeName) => typeName.FullName == typeof(int).FullName 620Resolver = (TypeName typeName) => typeName.FullName == typeof(int).FullName 708private static Type NullableIntArrayResolver(TypeName typeName) 738static Type TestDataResolver(TypeName typeName) 780static Type InvalidResolver(TypeName typeName) => null!; 847Resolver = (TypeName typeName) => 1089internal static Type MyExactMatchResolver(TypeName typeName) 1092(Type type, TypeName typeName)[] allowedTypes = 1094(typeof(MyClass1), TypeName.Parse(typeof(MyClass1).AssemblyQualifiedName)), 1095(typeof(MyClass2), TypeName.Parse(typeof(MyClass2).AssemblyQualifiedName))
System\Private\Windows\Ole\TestDataObject.cs (2)
89Func<TypeName, Type?> resolver, 96Func<TypeName, Type?>? resolver,
System\Private\Windows\Ole\TestDataObjectAdapter.cs (1)
44Func<TypeName, Type?> resolver,
System\Private\Windows\Ole\TypeBinderTests.cs (16)
61TypeName typeName = TypeName.Parse(type.AssemblyQualifiedName); 80Resolver = (TypeName typeName) => typeof(MyClass).Matches(typeName) ? typeof(MyClass) : null 87TypeName typeName = TypeName.Parse(type.AssemblyQualifiedName); 104TypeName typeName = TypeName.Parse(type.AssemblyQualifiedName); 118Resolver = (TypeName typeName) => typeof(MyClass) 123binder.TryBindToType(TypeName.Parse(typeof(int).AssemblyQualifiedName), out Type? boundType).Should().Be(true); 133Resolver = (TypeName typeName) => throw new NotSupportedException() 138binder.TryBindToType(TypeName.Parse(typeof(int).AssemblyQualifiedName), out Type? boundType).Should().Be(false); 148Resolver = (TypeName typeName) => null! 153binder.TryBindToType(TypeName.Parse(typeof(int).AssemblyQualifiedName), out Type? boundType).Should().Be(true); 161public static bool TryBindToType(TypeName typeName, [NotNullWhen(true)] out Type? type) 182public static bool TryBindToType(TypeName typeName, [NotNullWhen(true)] out Type? type) 204public static bool TryBindToType(TypeName typeName, [NotNullWhen(true)] out Type? type)
System\Reflection\Metadata\TypeNameComparerTests.cs (89)
10public static TheoryData<TypeName, Type> TypeNameComparer_FullyQualified_Success() => new() 12{ TypeName.Parse(typeof(int).AssemblyQualifiedName), typeof(int) }, 13{ TypeName.Parse($"{typeof(int).FullName}, {typeof(int).Assembly.FullName}"), typeof(int) }, 14{ TypeName.Parse(typeof(int[]).AssemblyQualifiedName), typeof(int[]) }, 15{ TypeName.Parse($"{typeof(int[]).FullName}, {typeof(int[]).Assembly.FullName}"), typeof(int[]) }, 16{ TypeName.Parse(typeof(List<int>).AssemblyQualifiedName), typeof(List<int>) }, 17{ TypeName.Parse($"{typeof(List<int>).FullName}, {typeof(List<int>).Assembly.FullName}"), typeof(List<int>) }, 18{ TypeName.Parse(typeof(TestType).AssemblyQualifiedName), typeof(TestType) }, 19{ TypeName.Parse($"{typeof(TestType).FullName}, {typeof(TestType).Assembly.FullName}"), typeof(TestType) }, 24public void DictionaryLookup_FullyQualified_Succeeds(TypeName name, Type expected) 26Dictionary<TypeName, Type> types = new(TypeNameComparer.FullyQualifiedMatch) 28{ TypeName.Parse(typeof(int).AssemblyQualifiedName), typeof(int) }, 29{ TypeName.Parse(typeof(int[]).AssemblyQualifiedName), typeof(int[]) }, 30{ TypeName.Parse(typeof(List<int>).AssemblyQualifiedName), typeof(List<int>) }, 31{ TypeName.Parse(typeof(TestType).AssemblyQualifiedName), typeof(TestType) }, 38public static TheoryData<TypeName> TypeNameComparer_FullyQualified_Fail() => 40TypeName.Parse("System.Int32[], System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"), 41TypeName.Parse("System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"), 42TypeName.Parse("System.Int32, System.Private.CoreLib, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"), 43TypeName.Parse($"System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], {typeof(List<int>).Assembly.FullName}"), 44TypeName.Parse($"{typeof(TestType).FullName}, {typeof(int).Assembly.FullName}") 51public void DictionaryLookup_FullyQualified_VersionMismatch(TypeName name) 53Dictionary<TypeName, Type> types = new(TypeNameComparer.FullyQualifiedMatch) 55{ TypeName.Parse(typeof(int).AssemblyQualifiedName), typeof(int) }, 56{ TypeName.Parse(typeof(int[]).AssemblyQualifiedName), typeof(int[]) }, 57{ TypeName.Parse(typeof(List<int>).AssemblyQualifiedName), typeof(List<int>) }, 58{ TypeName.Parse(typeof(TestType).AssemblyQualifiedName), typeof(TestType) }, 67Dictionary<TypeName, Type> types = new(TypeNameComparer.FullyQualifiedMatch) 69{ TypeName.Parse(typeof(int).AssemblyQualifiedName), typeof(int) }, 70{ TypeName.Parse(typeof(int[]).AssemblyQualifiedName), typeof(int[]) }, 71{ TypeName.Parse(typeof(List<int>).AssemblyQualifiedName), typeof(List<int>) }, 72{ TypeName.Parse(typeof(TestType).AssemblyQualifiedName), typeof(TestType) }, 75TypeName name = TypeName.Parse(typeof(int).AssemblyQualifiedName); 78name = TypeName.Parse(testName); 88comparer.Equals(null, TypeName.Parse(typeof(int).AssemblyQualifiedName)).Should().BeFalse(); 89comparer.Equals(TypeName.Parse(typeof(int).AssemblyQualifiedName), null).Should().BeFalse(); 91TypeName.Parse(typeof(int).AssemblyQualifiedName), 92TypeName.Parse($"{typeof(int).FullName}, {typeof(int).Assembly.FullName}")).Should().BeTrue(); 100int hash = comparer.GetHashCode(TypeName.Parse(typeof(int).AssemblyQualifiedName)); 101comparer.GetHashCode(TypeName.Parse(typeof(int).AssemblyQualifiedName)).Should().Be(hash); 102comparer.GetHashCode(TypeName.Parse($"{typeof(int).FullName}, {typeof(int).Assembly.FullName}")).Should().Be(hash); 105public static TheoryData<TypeName, Type> TypeNameComparer_FullNameMatch_Success() => new() 107{ TypeName.Parse("System.Int32"), typeof(int) }, 108{ TypeName.Parse("System.Int32[]"), typeof(int[]) }, 109{ TypeName.Parse("System.Collections.Generic.List`1[[System.Int32]]"), typeof(List<int>) }, 110{ TypeName.Parse(typeof(TestType).FullName), typeof(TestType) }, 117public void DictionaryLookup_FullNameMatch_Succeeds(TypeName name, Type expected) 119var types = new Dictionary<TypeName, Type>(TypeNameComparer.FullNameMatch) 121{ TypeName.Parse(typeof(int).FullName), typeof(int) }, 122{ TypeName.Parse(typeof(int[]).FullName), typeof(int[]) }, 123{ TypeName.Parse(typeof(List<int>).FullName), typeof(List<int>) }, 124{ TypeName.Parse(typeof(TestType).FullName), typeof(TestType) }, 131public static TheoryData<TypeName> TypeNameComparer_FullNameMatch_Fail() => 133TypeName.Parse("UnknownType"), 134TypeName.Parse("List`1[[UnknownType]]"), 135TypeName.Parse("Int32"), 136TypeName.Parse("Int32[]"), 137TypeName.Parse("System.Collections.Generic.List`1[[Int32]]"), 138TypeName.Parse(nameof(TestType)) 143public void DictionaryLookup_FullNameMatch_Fails(TypeName name) 145var types = new Dictionary<TypeName, Type>(TypeNameComparer.FullNameMatch) 147{ TypeName.Parse(typeof(int).FullName), typeof(int) }, 148{ TypeName.Parse(typeof(int[]).FullName), typeof(int[]) }, 149{ TypeName.Parse(typeof(List<int>).FullName), typeof(List<int>) }, 150{ TypeName.Parse(typeof(TestType).FullName), typeof(TestType) }, 156public static TheoryData<TypeName, Type> TypeNameComparer_FullNameAndAssemblyNameMatch_Success() => new() 158{ TypeName.Parse($"{typeof(int).FullName}, {typeof(int).Assembly.GetName().Name}"), typeof(int) }, 159{ TypeName.Parse($"{typeof(int[]).FullName}, {typeof(int).Assembly.GetName().Name}"), typeof(int[]) }, 160{ TypeName.Parse($"{typeof(List<int>).FullName}, {typeof(List<int>).Assembly.GetName().Name}"), typeof(List<int>) }, 161{ TypeName.Parse($"{typeof(TestType).FullName}, {typeof(TestType).Assembly.GetName().Name}"), typeof(TestType) }, 167public void DictionaryLookup_FullNameAndAssemblyNameMatch_Succeeds(TypeName name, Type expected) 169var types = new Dictionary<TypeName, Type>(TypeNameComparer.FullNameAndAssemblyNameMatch) 171{ TypeName.Parse($"{typeof(int).FullName}, {typeof(int).Assembly.GetName().Name}"), typeof(int) }, 172{ TypeName.Parse($"{typeof(int[]).FullName}, {typeof(int).Assembly.GetName().Name}"), typeof(int[]) }, 173{ TypeName.Parse($"{typeof(List<int>).FullName}, {typeof(List<int>).Assembly.GetName().Name}"), typeof(List<int>) }, 174{ TypeName.Parse($"{typeof(TestType).FullName}, {typeof(TestType).Assembly.GetName().Name}"), typeof(TestType) }, 181public static TheoryData<TypeName> TypeNameComparer_FullNameAndAssemblyNameMatch_Fail() => new() 184TypeName.Parse($"{typeof(int).FullName}, SomeOtherAssembly"), 186TypeName.Parse($"SomeNamespace.SomeType, {typeof(int).Assembly.GetName().Name}"), 188TypeName.Parse("SomeNamespace.SomeType, SomeOtherAssembly"), 190TypeName.Parse($"{typeof(int).FullName}"), 192TypeName.Parse($"System.String, {typeof(int).Assembly.GetName().Name}"), 198public void DictionaryLookup_FullNameAndAssemblyNameMatch_Fails(TypeName name) 200var types = new Dictionary<TypeName, Type>(TypeNameComparer.FullNameAndAssemblyNameMatch) 202{ TypeName.Parse($"{typeof(int).FullName}, {typeof(int).Assembly.GetName().Name}"), typeof(int) }, 203{ TypeName.Parse($"{typeof(int[]).FullName}, {typeof(int).Assembly.GetName().Name}"), typeof(int[]) }, 204{ TypeName.Parse($"{typeof(List<int>).FullName}, {typeof(List<int>).Assembly.GetName().Name}"), typeof(List<int>) }, 205{ TypeName.Parse($"{typeof(TestType).FullName}, {typeof(TestType).Assembly.GetName().Name}"), typeof(TestType) },
System\TypeExtensionsTests.cs (45)
12public static TheoryData<Type, TypeName, int, bool> Matches_Type_Data() => new() 14{ typeof(int), TypeName.Parse(typeof(int).AssemblyQualifiedName), (int)TypeNameComparison.All, true }, 15{ typeof(int), TypeName.Parse(typeof(int).AssemblyQualifiedName), (int)TypeNameComparison.AllButAssemblyVersion, true }, 16{ typeof(int), TypeName.Parse(typeof(int).AssemblyQualifiedName), (int)TypeNameComparison.TypeFullName, true }, 17{ typeof(int), TypeName.Parse(typeof(int).AssemblyQualifiedName), (int)TypeNameComparison.AssemblyVersion, true }, 18{ typeof(int), TypeName.Parse(typeof(int).AssemblyQualifiedName), (int)TypeNameComparison.AssemblyCultureName, true }, 19{ typeof(int), TypeName.Parse(typeof(int).AssemblyQualifiedName), (int)TypeNameComparison.AssemblyName, true }, 20{ typeof(int), TypeName.Parse(typeof(int).AssemblyQualifiedName), (int)TypeNameComparison.AssemblyPublicKeyToken, true }, 21{ typeof(int), TypeName.Parse($"System.Int32, {Assemblies.Mscorlib}"), (int)TypeNameComparison.AllButAssemblyVersion, false }, 22{ typeof(int), TypeName.Parse($"System.Int32, {Assemblies.Mscorlib}"), (int)TypeNameComparison.TypeFullName, true }, 23{ typeof(int), TypeName.Parse($"Int32, {Assemblies.Mscorlib}"), (int)TypeNameComparison.TypeFullName, false }, 24{ typeof(int?), TypeName.Parse(typeof(int).AssemblyQualifiedName), (int)TypeNameComparison.AllButAssemblyVersion, false }, 25{ typeof(int?), TypeName.Parse(typeof(int?).AssemblyQualifiedName), (int)TypeNameComparison.All, true }, 26{ typeof(int?[]), TypeName.Parse($"System.Nullable`1[[System.Int32, {Assemblies.Mscorlib}]][], {Assemblies.Mscorlib}"), (int)TypeNameComparison.AllButAssemblyVersion, false}, 27{ typeof(DayOfWeek), TypeName.Parse($"System.Nullable`1[[System.DayOfWeek, {Assemblies.Mscorlib}]], {Assemblies.Mscorlib}"), (int)TypeNameComparison.AllButAssemblyVersion, false }, 29{ typeof(int), TypeName.Parse(typeof(int).AssemblyQualifiedName!.Replace("neutral", "en-US")), (int)TypeNameComparison.AssemblyCultureName, false }, 31{ typeof(int), TypeName.Parse("Int32"), (int)TypeNameComparison.TypeFullName, false }, 33{ typeof(int), TypeName.Parse("SYSTEM.Int32"), (int)TypeNameComparison.TypeFullName, false }, 35{ typeof(int), TypeName.Parse("System.Int32"), (int)TypeNameComparison.AllButAssemblyVersion, false }, 37{ typeof(int), TypeName.Parse($"System.Int32, {typeof(int).Assembly.FullName!.ToUpperInvariant()}"), (int)TypeNameComparison.AssemblyName, false }, 42public void Matches_Type(Type type, TypeName typeName, int comparison, bool matches) 45TypeName.Parse(type.AssemblyQualifiedName).Matches(typeName, (TypeNameComparison)comparison).Should().Be(matches); 54TypeName.Parse(typeof(int).AssemblyQualifiedName!.Replace("7cec85d7bea7798e", "7cec00000ea7798e")), 59public static TheoryData<TypeName, TypeName, bool> Matches_Type_Mscorlib_Data() => new() 61{ TypeName.Parse($"System.Int32, {Assemblies.Mscorlib}"), TypeName.Parse($"System.Int32, {Assemblies.Mscorlib}"), true }, 62{ TypeName.Parse($"System.Int32, {Assemblies.Mscorlib}"), TypeName.Parse($"System.String, {Assemblies.Mscorlib}"), false }, 63{ TypeName.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Assemblies.Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Assemblies.Mscorlib}"), TypeName.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Assemblies.Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Assemblies.Mscorlib}"), true }, 64{ TypeName.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Assemblies.Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Assemblies.Mscorlib}"), TypeName.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Assemblies.Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Assemblies.Mscorlib}"), false }, 65{ TypeName.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Assemblies.Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Assemblies.Mscorlib}"), TypeName.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Assemblies.Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], mscorlib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"), false }, 66{ TypeName.Parse($"System.Drawing.Bitmap[], System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), TypeName.Parse($"System.Drawing.Bitmap[], System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), true }, 67{ TypeName.Parse($"System.Drawing.Bitmap[], System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), TypeName.Parse($"System.Drawing.Bitmap[], System.Drawing, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), false }, 68{ TypeName.Parse($"System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), TypeName.Parse($"System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), true }, 69{ TypeName.Parse($"System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), TypeName.Parse($"System.Drawing.Bitmap, System.Drawing, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), false }, 74public void Matches_Type_Mscorlib(TypeName x, TypeName y, bool matches) =>
System.Reflection.Metadata (59)
System\Reflection\Metadata\TypeName.cs (47)
35private readonly TypeName? _elementOrGenericType; 36private readonly TypeName? _declaringType; 40private readonly ImmutableArray<TypeName> _genericArguments; 46TypeName? elementOrGenericType = default, 47TypeName? declaringType = default, 51ImmutableArray<TypeName>.Builder? genericTypeArguments = default, 67? ImmutableArray<TypeName>.Empty 75TypeName? elementOrGenericType, 76TypeName? declaringType, 77ImmutableArray<TypeName> genericTypeArguments, 133/// Returns assembly name which contains this type, or null if this <see cref="TypeName"/> was not 146public TypeName DeclaringType 210foreach (TypeName genericArg in GetGenericArguments()) 376TypeName rootTypeName = this; 414/// Represents the total number of <see cref="TypeName"/> instances that are used to describe 420/// as the total number of <see cref="TypeName"/> instances that would be created if 421/// you were to totally deconstruct this instance and visit each intermediate <see cref="TypeName"/> 428/// involves inspecting 8 <see cref="TypeName"/> instances total: 441/// <exception cref="OverflowException">The total number of <see cref="TypeName"/> instances that are used to describe 459foreach (TypeName genericArgument in GetGenericArguments()) 479public TypeName GetElementType() 496public TypeName GetGenericTypeDefinition() 514public static TypeName Parse(ReadOnlySpan<char> typeName, TypeNameParseOptions? options = default) 524public static bool TryParse(ReadOnlySpan<char> typeName, [NotNullWhen(true)] out TypeName? result, TypeNameParseOptions? options = default) 565/// If this <see cref="TypeName"/> represents a constructed generic type, returns an array 576ImmutableArray<TypeName> GetGenericArguments() => _genericArguments; 581/// Creates a new <see cref="TypeName" /> object that represents current simple name with provided assembly name. 586public TypeName WithAssemblyName(AssemblyNameInfo? assemblyName) 604TypeName? declaringType = IsNested 612genericTypeArguments: ImmutableArray<TypeName>.Empty, 617/// Creates a <see cref="TypeName" /> object representing a one-dimensional array 621/// A <see cref="TypeName" /> object representing a one-dimensional array 624public TypeName MakeSZArrayTypeName() => MakeElementTypeName(TypeNameParserHelpers.SZArray); 627/// Creates a <see cref="TypeName" /> object representing an array of the current type, 632/// A <see cref="TypeName" /> object representing an array of the current type, 636public TypeName MakeArrayTypeName(int rank) 642/// Creates a <see cref="TypeName" /> object that represents a pointer to the current type. 645/// A <see cref="TypeName" /> object that represents a pointer to the current type. 647public TypeName MakePointerTypeName() => MakeElementTypeName(TypeNameParserHelpers.Pointer); 650/// Creates a <see cref="TypeName" /> object that represents a managed reference to the current type. 653/// A <see cref="TypeName" /> object that represents a managed reference to the current type. 655public TypeName MakeByRefTypeName() => MakeElementTypeName(TypeNameParserHelpers.ByRef); 662/// A <see cref="TypeName" /> representing the constructed type name formed by using the elements 666public TypeName MakeGenericTypeName(ImmutableArray<TypeName> typeArguments) 676private TypeName MakeElementTypeName(int rankOrModifier) 682genericTypeArguments: ImmutableArray<TypeName>.Empty,
System\Reflection\Metadata\TypeNameParser.cs (10)
31internal static TypeName? Parse(ReadOnlySpan<char> typeName, bool throwOnError, TypeNameParseOptions? options = default) 46TypeName? parsedName = parser.ParseNextTypeName(allowFullyQualifiedName: true, ref recursiveDepth); 70private TypeName? ParseNextTypeName(bool allowFullyQualifiedName, ref int recursiveDepth) 92ImmutableArray<TypeName>.Builder? genericArgs = null; 108TypeName? genericArg = ParseNextTypeName(allowFullyQualifiedName: doubleBrackets, ref recursiveDepth); 125genericArgs = ImmutableArray.CreateBuilder<TypeName>(2); 206TypeName? declaringType = GetDeclaringType(fullName, nestedNameLengths, assemblyName); 207TypeName result = new(fullName, assemblyName, declaringType: declaringType); 252private static TypeName? GetDeclaringType(string fullTypeName, List<int>? nestedNameLengths, AssemblyNameInfo? assemblyName) 261TypeName? declaringType = null;
System\Reflection\Metadata\TypeNameParserOptions.cs (2)
11/// Limits the maximum value of <seealso cref="TypeName.GetNodeCount">node count</seealso> that parser can handle. 15/// Setting this to a large value can render <see cref="TypeName"/> susceptible to Denial of Service
System.Resources.Extensions (3)
System\Resources\Extensions\BinaryFormat\BinaryFormattedObject.ITypeResolver.cs (1)
21Type GetType(TypeName typeName);
System\Resources\Extensions\BinaryFormat\BinaryFormattedObject.TypeResolver.cs (2)
38Type ITypeResolver.GetType(TypeName typeName) 88private static Type? GetSimplyNamedTypeFromAssembly(Assembly assembly, TypeName typeName)
System.Windows.Forms (25)
System\Resources\ResXSerializationBinder.cs (4)
40if (_typeResolver is null || !TypeName.TryParse($"{typeName}, {assemblyName}".AsSpan(), out TypeName? parsed)) 83&& TypeName.TryParse(assemblyQualifiedTypeName.AsSpan(), out TypeName? parsed)
System\Windows\Forms\Nrbf\WinFormsNrbfSerializer.cs (2)
17private static Dictionary<TypeName, Type>? s_knownTypes; 22public static bool TryBindToType(TypeName typeName, [NotNullWhen(true)] out Type? type)
System\Windows\Forms\OLE\Clipboard.cs (9)
165/// <see cref="TypeName"/> is allowed or throws a <see cref="NotSupportedException"/> if <see cref="TypeName"/> is not 189/// <see cref="TypeName"/> parameter can be matched according to the user requirements, for example, only namespace-qualified 229/// Avoid loading assemblies named in the <see cref="TypeName"/> argument of your <paramref name="resolver"/>. 235/// should be aware of <see cref="TypeName"/>s coming in with either .NET Framework assembly names or .NET ones. 243/// <see cref="TypeName.FullName"/> property. 307Func<TypeName, Type?> resolver, 325/// You must use the <see cref="TryGetData{T}(string, Func{TypeName, Type?}, out T)"/> with an explicit resolver. 339/// <inheritdoc cref="TryGetData{T}(string, Func{TypeName, Type}, out T)"/>
System\Windows\Forms\OLE\DataObject.cs (5)
150/// <inheritdoc cref="Clipboard.TryGetData{T}(string, Func{TypeName, Type}, out T)"/> 154Func<TypeName, Type?> resolver, 183/// <inheritdoc cref="ITypedDataObject.TryGetData{T}(string, Func{TypeName, Type}, bool, out T)" /> 187Func<TypeName, Type?>? resolver, 264Func<TypeName, Type?>? resolver,
System\Windows\Forms\OLE\DataObjectAdapter.cs (1)
41Func<TypeName, Type?> resolver,
System\Windows\Forms\OLE\DataObjectExtensions.cs (2)
52/// <inheritdoc cref="ITypedDataObject.TryGetData{T}(string, Func{Reflection.Metadata.TypeName, Type}, bool, out T)"/> 59Func<Reflection.Metadata.TypeName, Type?> resolver,
System\Windows\Forms\OLE\ITypedDataObject.cs (2)
39/// <inheritdoc cref="IDataObjectInternal.TryGetData{T}(string, Func{TypeName, Type}, bool, out T)" /> 43Func<TypeName, Type?> resolver,
System.Windows.Forms.Tests (26)
System\Resources\ResXSerializationBinderTests.cs (2)
86TypeName parsed = TypeName.Parse($"{typeof(Form).FullName}, {typeof(Form).Assembly.FullName}");
System\Windows\Forms\BinaryFormat\WinFormsBinaryFormattedObjectTests.cs (2)
95if (TypeName.TryParse(InnerTypeAssemblyQualifiedName, out TypeName? innerTypeName)
System\Windows\Forms\ClipboardTests.cs (9)
778public static Type TestDataResolver(TypeName typeName) 1056TypeName.TryParse(innerTypeAssemblyQualifiedName, out TypeName? innerTypeName).Should().BeTrue(); 1057TypeName checkedResult = innerTypeName.Should().BeOfType<TypeName>().Subject; 1337(TypeName name) => name.FullName == typeof(SerializableTestData).FullName ? typeof(SerializableTestData) : null, 1345(TypeName name) => name.FullName == typeof(SerializableTestData).FullName ? typeof(SerializableTestData) : null, 1387(TypeName name) => name.FullName == typeof(SerializableTestData).FullName ? typeof(SerializableTestData) : null, 1405(TypeName name) => name.FullName == typeof(SerializableTestData).FullName ? typeof(SerializableTestData) : null,
System\Windows\Forms\DataObjectExtensionsTests.cs (2)
30private static Type Resolver(TypeName typeName) => typeof(string); 252public bool TryGetData<T>(string format, Func<TypeName, Type?> resolver, bool autoConvert, [MaybeNullWhen(false), NotNullWhen(true)] out T data)
System\Windows\Forms\DataObjectTests.cs (5)
377private readonly Func<TypeName, Type>? _resolver; 381public DataObjectOverridesTryGetDataCore(string format, Func<TypeName, Type>? resolver, bool autoConvert) : base() 389public static Type Resolver(TypeName _) => typeof(string); 393Func<TypeName, Type?>? resolver, 523private static Type NotSupportedResolver(TypeName typeName) => throw new NotSupportedException();
System\Windows\Forms\NativeToWinFormsAdapterTests.cs (4)
44(TypeName typeName) => typeof(int).Matches(typeName, TypeNameComparison.TypeFullName) ? typeof(int) : null, 66static Type Resolver(TypeName typeName) => typeof(int); 489public static Type Resolver(TypeName typeName) 547public static Type? Resolver(TypeName typeName)
System\Windows\Forms\Ole\BinaryFormatUtilitiesTests.cs (2)
19Func<TypeName, Type>? resolver, 69private static Type FontResolver(TypeName typeName)
System.Windows.Forms.TestUtilities (2)
Data\TypedAndRuntimeDataObject.cs (1)
32Func<TypeName, Type?> resolver,
Data\TypedDataObject.cs (1)
31Func<TypeName, Type?> resolver,