7 instantiations of TypeName
System.Reflection.Metadata (7)
System\Reflection\Metadata\TypeName.cs (3)
463
return new
TypeName
(fullName: _fullName,
528
return new
TypeName
(fullName: null, AssemblyName, elementOrGenericType: this, declaringType: _declaringType, genericTypeArguments: typeArguments);
532
=> new
TypeName
(
System\Reflection\Metadata\TypeNameParser.cs (4)
207
TypeName result =
new
(fullName, assemblyName, declaringType: declaringType);
210
result =
new
(fullName: null, assemblyName, elementOrGenericType: result, declaringType, genericArgs);
220
result =
new
(fullName: null, assemblyName, elementOrGenericType: result, rankOrModifier: parsedModifier);
267
declaringType =
new
(fullTypeName, assemblyName, declaringType: declaringType, nestedNameLength: fullNameLength);
331 references to TypeName
illink (12)
Linker\TypeNameResolver.cs (7)
9
using TypeName = System.Reflection.Metadata.
TypeName
;
40
if (!
TypeName
.TryParse (typeNameString, out
TypeName
? parsedTypeName, s_typeNameParseOptions)) {
52
TypeReference? ResolveTypeName (AssemblyDefinition originalAssembly,
TypeName
? typeName, List<TypeResolutionRecord> typeResolutionRecords)
72
foreach (
var
arg in typeName.GetGenericArguments()) {
97
TypeName
topLevelTypeName = typeName;
125
TypeDefinition? GetSimpleTypeFromModule (
TypeName
typeName, ModuleDefinition module)
Linker\TypeNameResolver.WithDiagnostics.cs (5)
11
using TypeName = System.Reflection.Metadata.
TypeName
;
29
if (!
TypeName
.TryParse (typeNameString, out
TypeName
? parsedTypeName, s_typeNameParseOptions))
56
static bool IsFullyQualified (
TypeName
typeName)
65
foreach (
var
typeArgument in typeName.GetGenericArguments ()) {
Microsoft.VisualBasic.Forms (2)
Microsoft\VisualBasic\MyServices\ClipboardProxy.vb (2)
195
''' <inheritdoc cref="Clipboard.TryGetData(Of T)(String, Func(Of
TypeName
, Type), ByRef T)" />
196
Public 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)
154
public static Type Resolver(
TypeName
typeName) =>
System.Formats.Nrbf (61)
System\Formats\Nrbf\ArrayRectangularPrimitiveRecord.cs (2)
22
private
TypeName
? _typeName;
35
public override
TypeName
TypeName
System\Formats\Nrbf\ArraySingleObjectRecord.cs (1)
24
public override
TypeName
TypeName
System\Formats\Nrbf\ArraySinglePrimitiveRecord.cs (1)
36
public override
TypeName
TypeName => TypeNameHelpers.GetPrimitiveSZArrayTypeName(TypeNameHelpers.GetPrimitiveType<T>());
System\Formats\Nrbf\ArraySingleStringRecord.cs (1)
25
public override
TypeName
TypeName => TypeNameHelpers.GetPrimitiveSZArrayTypeName(TypeNameHelpers.StringPrimitiveType);
System\Formats\Nrbf\BinaryLibraryRecord.cs (2)
33
public override
TypeName
TypeName =>
TypeName
.Parse(nameof(BinaryLibraryRecord).AsSpan());
System\Formats\Nrbf\ClassInfo.cs (2)
23
private
TypeName
? _typeName;
34
internal
TypeName
TypeName
System\Formats\Nrbf\ClassRecord.cs (1)
23
public override
TypeName
TypeName => ClassInfo.TypeName;
System\Formats\Nrbf\ClassTypeInfo.cs (2)
20
internal ClassTypeInfo(
TypeName
typeName) => TypeName = typeName;
22
internal
TypeName
TypeName { get; }
System\Formats\Nrbf\JaggedArrayRecord.cs (2)
26
private
TypeName
? _typeName;
43
public override
TypeName
TypeName => _typeName ??= _memberTypeInfo.GetArrayTypeName(ArrayInfo);
System\Formats\Nrbf\MemberReferenceRecord.cs (1)
34
public override
TypeName
TypeName => GetReferencedRecord().TypeName;
System\Formats\Nrbf\MemberTypeInfo.cs (3)
111
internal
TypeName
GetArrayTypeName(ArrayInfo arrayInfo)
115
TypeName
elementTypeName = binaryType switch
123
BinaryType.SystemClass => (
TypeName
)additionalInfo!,
System\Formats\Nrbf\MessageEndRecord.cs (2)
27
public override
TypeName
TypeName =>
TypeName
.Parse(nameof(MessageEndRecord).AsSpan());
System\Formats\Nrbf\NrbfDecoder.cs (5)
398
TypeName
typeName = binaryType == BinaryType.SystemClass ? (
TypeName
)additionalInfo! : ((ClassTypeInfo)additionalInfo!).TypeName;
414
TypeName
typeName = binaryType == BinaryType.SystemClass ? (
TypeName
)additionalInfo! : ((ClassTypeInfo)additionalInfo!).TypeName;
448
else if (binaryType == BinaryType.SystemClass && ((
TypeName
)additionalInfo!).IsArray)
System\Formats\Nrbf\NullsRecord.cs (2)
15
public 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)
37
public override
TypeName
TypeName => TypeNameHelpers.GetPrimitiveTypeName(TypeNameHelpers.GetPrimitiveType<T>());
System\Formats\Nrbf\RectangularArrayRecord.cs (2)
23
private
TypeName
? _typeName;
41
public override
TypeName
TypeName
System\Formats\Nrbf\SerializationRecord.cs (3)
42
public abstract
TypeName
TypeName { get; }
68
private static bool Matches(Type type,
TypeName
typeName)
128
ImmutableArray<
TypeName
> genericNames = typeName.GetGenericArguments();
System\Formats\Nrbf\SerializedStreamHeaderRecord.cs (2)
27
public override
TypeName
TypeName =>
TypeName
.Parse(nameof(SerializedStreamHeaderRecord).AsSpan());
System\Formats\Nrbf\SystemClassWithMembersAndTypesRecord.cs (1)
31
TypeName
typeName = classInfo.TypeName;
System\Formats\Nrbf\SZArrayOfRecords.cs (2)
17
private
TypeName
? _typeName;
32
public override
TypeName
TypeName
System\Formats\Nrbf\Utils\TypeNameHelpers.cs (22)
20
private static readonly
TypeName
?[] s_primitiveTypeNames = new
TypeName
?[(int)UIntPtrPrimitiveType + 1];
21
private static readonly
TypeName
?[] s_primitiveSZArrayTypeNames = new
TypeName
?[(int)UIntPtrPrimitiveType + 1];
24
internal static
TypeName
GetPrimitiveTypeName(PrimitiveType primitiveType)
26
TypeName
? typeName = s_primitiveTypeNames[(int)primitiveType];
53
s_primitiveTypeNames[(int)primitiveType] = typeName =
TypeName
.Parse(fullName.AsSpan()).WithCoreLibAssemblyName();
58
internal static
TypeName
GetPrimitiveSZArrayTypeName(PrimitiveType primitiveType)
60
TypeName
? typeName = s_primitiveSZArrayTypeNames[(int)primitiveType];
110
internal static
TypeName
ParseNonSystemClassRecordTypeName(this string rawName, BinaryLibraryRecord libraryRecord, PayloadOptions payloadOptions)
133
TypeName
.TryParse(assemblyQualifiedName.AsSpan(), out
TypeName
? typeName, payloadOptions.TypeNameParseOptions);
153
internal static
TypeName
ParseSystemRecordTypeName(this string rawName, PayloadOptions payloadOptions)
157
internal static
TypeName
WithCoreLibAssemblyName(this
TypeName
systemType)
160
private static
TypeName
With(this
TypeName
typeName, AssemblyNameInfo assemblyName)
170
TypeName
newElementType = typeName.GetElementType().With(assemblyName);
178
TypeName
newGenericTypeDefinition = typeName.GetGenericTypeDefinition().With(assemblyName);
193
private static
TypeName
ParseWithoutAssemblyName(string rawName, PayloadOptions payloadOptions)
195
if (!
TypeName
.TryParse(rawName.AsSpan(), out
TypeName
? typeName, payloadOptions.TypeNameParseOptions)
System.Private.Windows.Core (3)
System\Private\Windows\Core\BinaryFormat\Deserializer\DefaultTypeResolver.cs (2)
30
Type ITypeResolver.GetType(
TypeName
typeName)
82
private static Type? GetSimplyNamedTypeFromAssembly(Assembly assembly,
TypeName
typeName)
System\Private\Windows\Core\BinaryFormat\ITypeResolver.cs (1)
18
Type GetType(
TypeName
typeName);
System.Reflection.Metadata (59)
System\Reflection\Metadata\TypeName.cs (45)
35
private readonly
TypeName
? _elementOrGenericType;
36
private readonly
TypeName
? _declaringType;
40
private readonly ImmutableArray<
TypeName
> _genericArguments;
46
TypeName
? elementOrGenericType = default,
47
TypeName
? declaringType = default,
51
ImmutableArray<
TypeName
>.Builder? genericTypeArguments = default,
67
? ImmutableArray<
TypeName
>.Empty
75
TypeName
? elementOrGenericType,
76
TypeName
? declaringType,
77
ImmutableArray<
TypeName
> genericTypeArguments,
101
/// Returns assembly name which contains this type, or null if this <see cref="
TypeName
"/> was not
114
public
TypeName
DeclaringType
288
/// Represents the total number of <see cref="
TypeName
"/> instances that are used to describe
294
/// as the total number of <see cref="
TypeName
"/> instances that would be created if
295
/// you were to totally deconstruct this instance and visit each intermediate <see cref="
TypeName
"/>
302
/// involves inspecting 8 <see cref="
TypeName
"/> instances total:
315
/// <exception cref="OverflowException">The total number of <see cref="
TypeName
"/> instances that are used to describe
333
foreach (
TypeName
genericArgument in GetGenericArguments())
353
public
TypeName
GetElementType()
370
public
TypeName
GetGenericTypeDefinition()
388
public static
TypeName
Parse(ReadOnlySpan<char> typeName, TypeNameParseOptions? options = default)
398
public static bool TryParse(ReadOnlySpan<char> typeName, [NotNullWhen(true)] out
TypeName
? result, TypeNameParseOptions? options = default)
420
/// If this <see cref="
TypeName
"/> represents a constructed generic type, returns an array
431
ImmutableArray<
TypeName
> GetGenericArguments() => _genericArguments;
436
/// Creates a new <see cref="
TypeName
" /> object that represents current simple name with provided assembly name.
441
public
TypeName
WithAssemblyName(AssemblyNameInfo? assemblyName)
459
TypeName
? declaringType = IsNested
467
genericTypeArguments: ImmutableArray<
TypeName
>.Empty,
472
/// Creates a <see cref="
TypeName
" /> object representing a one-dimensional array
476
/// A <see cref="
TypeName
" /> object representing a one-dimensional array
479
public
TypeName
MakeSZArrayTypeName() => MakeElementTypeName(TypeNameParserHelpers.SZArray);
482
/// Creates a <see cref="
TypeName
" /> object representing an array of the current type,
487
/// A <see cref="
TypeName
" /> object representing an array of the current type,
491
public
TypeName
MakeArrayTypeName(int rank)
497
/// Creates a <see cref="
TypeName
" /> object that represents a pointer to the current type.
500
/// A <see cref="
TypeName
" /> object that represents a pointer to the current type.
502
public
TypeName
MakePointerTypeName() => MakeElementTypeName(TypeNameParserHelpers.Pointer);
505
/// Creates a <see cref="
TypeName
" /> object that represents a managed reference to the current type.
508
/// A <see cref="
TypeName
" /> object that represents a managed reference to the current type.
510
public
TypeName
MakeByRefTypeName() => MakeElementTypeName(TypeNameParserHelpers.ByRef);
517
/// A <see cref="
TypeName
" /> representing the constructed type name formed by using the elements
521
public
TypeName
MakeGenericTypeName(ImmutableArray<
TypeName
> typeArguments)
531
private
TypeName
MakeElementTypeName(int rankOrModifier)
537
genericTypeArguments: ImmutableArray<
TypeName
>.Empty,
System\Reflection\Metadata\TypeNameParser.cs (10)
31
internal static
TypeName
? Parse(ReadOnlySpan<char> typeName, bool throwOnError, TypeNameParseOptions? options = default)
46
TypeName
? parsedName = parser.ParseNextTypeName(allowFullyQualifiedName: true, ref recursiveDepth);
70
private
TypeName
? ParseNextTypeName(bool allowFullyQualifiedName, ref int recursiveDepth)
92
ImmutableArray<
TypeName
>.Builder? genericArgs = null;
108
TypeName
? genericArg = ParseNextTypeName(allowFullyQualifiedName: doubleBrackets, ref recursiveDepth);
125
genericArgs = ImmutableArray.CreateBuilder<
TypeName
>(2);
206
TypeName
? declaringType = GetDeclaringType(fullName, nestedNameLengths, assemblyName);
207
TypeName
result = new(fullName, assemblyName, declaringType: declaringType);
252
private static
TypeName
? GetDeclaringType(string fullTypeName, List<int>? nestedNameLengths, AssemblyNameInfo? assemblyName)
261
TypeName
? declaringType = null;
System\Reflection\Metadata\TypeNameParserHelpers.cs (2)
23
internal static string GetGenericTypeFullName(ReadOnlySpan<char> fullTypeName, ReadOnlySpan<
TypeName
> genericArgs)
31
foreach (
TypeName
genericArg in genericArgs)
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)
21
Type GetType(
TypeName
typeName);
System\Resources\Extensions\BinaryFormat\BinaryFormattedObject.TypeResolver.cs (2)
38
Type ITypeResolver.GetType(
TypeName
typeName)
88
private static Type? GetSimplyNamedTypeFromAssembly(Assembly assembly,
TypeName
typeName)
System.Windows.Forms (69)
System\Resources\ResXSerializationBinder.cs (4)
40
if (_typeResolver is null || !
TypeName
.TryParse($"{typeName}, {assemblyName}".AsSpan(), out
TypeName
? parsed))
83
&&
TypeName
.TryParse(assemblyQualifiedTypeName.AsSpan(), out
TypeName
? parsed)
System\Windows\Forms\Internal\TypeExtensions.cs (14)
11
/// Helper methods for comparing <see cref="Type"/>s and <see cref="
TypeName
"/>s.
50
public static bool MatchExceptAssemblyVersion(this Type type,
TypeName
typeName)
67
private static bool MatchLessAssemblyVersion(this Type type,
TypeName
typeName)
114
ImmutableArray<
TypeName
> genericNames = typeName.GetGenericArguments();
160
/// Match <see cref="
TypeName
"/>s using all information that had been set by the caller.
162
public static bool Matches(this
TypeName
x,
TypeName
y)
196
ImmutableArray<
TypeName
> genericNamesY = y.GetGenericArguments();
197
ImmutableArray<
TypeName
> genericNamesX = x.GetGenericArguments();
238
/// Convert <paramref name="type"/> to <see cref="
TypeName
"/>. Take into account type forwarding in order
239
/// to create <see cref="
TypeName
"/> compatible with the type names serialized to the binary format.This
240
/// method removes nullability wrapper from the top level type only because <see cref="
TypeName
"/> in the
243
public static
TypeName
ToTypeName(this Type type)
252
return
TypeName
.Parse($"{GetTypeFullName(type)}, {assemblyName}");
System\Windows\Forms\Nrbf\WinFormsSerializationRecordExtensions.cs (2)
82
|| !
TypeName
.TryParse(innerTypeFullName, out
TypeName
? serializedTypeName))
System\Windows\Forms\OLE\Clipboard.cs (8)
266
/// <see cref="
TypeName
"/> is allowed or throws a <see cref="NotSupportedException"/> if <see cref="
TypeName
"/> is not
294
/// <see cref="
TypeName
"/> parameter can be matched according to the user requirements, for example, only namespace-qualified
311
/// Avoid loading assemblies named in the <see cref="
TypeName
"/> argument of the resolver function. Resolve only types
319
/// from the allowed type and match it to the <see cref="AssemblyNameInfo.FullName"/> property of <see cref="
TypeName
.AssemblyName"/>.
328
/// <see cref="
TypeName
.FullName"/> property. Resolver function should either remove or type-forward these assembly
390
Func<
TypeName
, Type> resolver,
400
/// <inheritdoc cref="TryGetData{T}(string, Func{
TypeName
, Type}, out T)"/>
System\Windows\Forms\OLE\DataObject.Composition.BinaryFormatUtilities.cs (3)
69
Func<
TypeName
, Type>? resolver,
161
Func<
TypeName
, Type>? resolver,
200
private static bool TypeNameIsAssignableToType(
TypeName
typeName, Type type, ITypeResolver resolver)
System\Windows\Forms\OLE\DataObject.Composition.Binder.cs (12)
31
private readonly Func<
TypeName
, Type>? _resolver;
108
private static Dictionary<
TypeName
, Type>? s_knownTypes;
110
private readonly Dictionary<
TypeName
, Type> _userTypes = new(TypeNameComparer.Default);
121
/// <see cref="
TypeName
"/>s read from the deserialized stream.
128
public Binder(Type type, Func<
TypeName
, Type>? resolver, bool legacyMode)
143
TypeName
typeName = type.ToTypeName();
246
TypeName
parsed =
TypeName
.Parse($"{typeName}, {assemblyName}");
252
private Type UseResolver(
TypeName
typeName)
270
private Type? GetCachedType(string assemblyName, string fullTypeName,
TypeName
? typeName)
274
typeName ??=
TypeName
.Parse($"{fullTypeName}, {assemblyName}");
283
public Type GetType(
TypeName
typeName)
System\Windows\Forms\OLE\DataObject.Composition.cs (1)
103
Func<
TypeName
, Type> resolver,
System\Windows\Forms\OLE\DataObject.Composition.NativeToWinFormsAdapter.cs (7)
97
Func<
TypeName
, Type>? resolver,
130
Func<
TypeName
, Type>? resolver,
255
Func<
TypeName
, Type>? resolver,
292
Func<
TypeName
, Type>? resolver,
355
Func<
TypeName
, Type>? resolver,
488
Func<
TypeName
, Type>? resolver,
632
Func<
TypeName
, Type> resolver,
System\Windows\Forms\OLE\DataObject.Composition.TypeNameComparer.cs (7)
12
/// Match <see cref="
TypeName
"/>s by matching full namespace-qualified type names and full assembly names,
15
internal sealed class TypeNameComparer : IEqualityComparer<
TypeName
>
21
internal static IEqualityComparer<
TypeName
> Default { get; } = new TypeNameComparer();
23
public bool Equals(
TypeName
? x,
TypeName
? y)
38
public int GetHashCode(
TypeName
obj)
54
foreach (
TypeName
genericName in obj.GetGenericArguments())
System\Windows\Forms\OLE\DataObject.cs (4)
269
Func<
TypeName
, Type> resolver,
298
/// <inheritdoc cref="ITypedDataObject.TryGetData{T}(string, Func{
TypeName
, Type}, bool, out T)" />
302
Func<
TypeName
, Type>? resolver,
376
Func<
TypeName
, Type>? resolver,
System\Windows\Forms\OLE\DataObject.DataStore.cs (1)
201
Func<
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)"/>
59
Func<Reflection.Metadata.
TypeName
, Type> resolver,
System\Windows\Forms\OLE\ITypedDataObject.cs (4)
28
/// <inheritdoc cref="TryGetData{T}(string, Func{
TypeName
, Type}, bool, out T)"/>
35
/// <inheritdoc cref="TryGetData{T}(string, Func{
TypeName
, Type}, bool, out T)"/>
44
/// <inheritdoc cref="TryGetData{T}(string, Func{
TypeName
, Type}, bool, out T)"/>
82
Func<
TypeName
, Type> resolver,
System.Windows.Forms.Tests (121)
System\Resources\ResXSerializationBinderTests.cs (2)
88
TypeName
parsed =
TypeName
.Parse($"{typeof(Form).FullName}, {typeof(Form).Assembly.FullName}");
System\Windows\Forms\BinaryFormat\WinFormsBinaryFormattedObjectTests.cs (2)
86
if (
TypeName
.TryParse(InnerTypeAssemblyQualifiedName, out
TypeName
? innerTypeName)
System\Windows\Forms\BinaryFormatUtilitiesTests.cs (14)
37
private object? ReadObjectFromStream<T>(bool restrictDeserialization, Func<
TypeName
, Type>? resolver)
45
private object? ReadObjectFromStream<T>(Func<
TypeName
, Type>? resolver)
51
private object? ReadRestrictedObjectFromStream<T>(Func<
TypeName
, Type>? resolver)
88
private object? RoundTripOfType<T>(object value, Func<
TypeName
, Type>? resolver)
436
static Type ObjectListResolver(
TypeName
typeName)
543
private static Type NullableIntArrayResolver(
TypeName
typeName)
574
static Type TestDataResolver(
TypeName
typeName)
611
static Type InvalidResolver(
TypeName
typeName) => null!;
614
private static Type FontResolver(
TypeName
typeName)
840
private static Type NotSupportedResolver(
TypeName
typeName) =>
996
internal static Type MyExactMatchResolver(
TypeName
typeName)
999
(Type type,
TypeName
typeName)[] allowedTypes =
1001
(typeof(MyClass1),
TypeName
.Parse(typeof(MyClass1).AssemblyQualifiedName)),
1002
(typeof(MyClass2),
TypeName
.Parse(typeof(MyClass2).AssemblyQualifiedName))
System\Windows\Forms\ClipboardTests.cs (5)
772
public static Type TestDataResolver(
TypeName
typeName)
1054
TypeName
.TryParse(innerTypeAssemblyQualifiedName, out
TypeName
? innerTypeName).Should().BeTrue();
1055
TypeName
checkedResult = innerTypeName.Should().BeOfType<
TypeName
>().Subject;
System\Windows\Forms\DataObjectExtensionsTests.cs (2)
32
private static Type Resolver(
TypeName
typeName) => typeof(string);
254
public bool TryGetData<T>(string format, Func<
TypeName
, Type> resolver, bool autoConvert, [MaybeNullWhen(false), NotNullWhen(true)] out T data)
System\Windows\Forms\DataObjectTests.cs (5)
378
private readonly Func<
TypeName
, Type>? _resolver;
382
public DataObjectOverridesTryGetDataCore(string format, Func<
TypeName
, Type>? resolver, bool autoConvert) : base()
390
public static Type Resolver(
TypeName
_) => typeof(string);
394
Func<
TypeName
, Type>? resolver,
471
private static Type NotSupportedResolver(
TypeName
typeName) => throw new NotSupportedException();
System\Windows\Forms\NativeToWinFormsAdapterTests.cs (3)
58
static Type Resolver(
TypeName
typeName) => typeof(int);
480
public static Type Resolver(
TypeName
typeName)
538
public static Type Resolver(
TypeName
typeName)
System\Windows\Forms\TypeExtensionsTests.cs (46)
15
public static TheoryData<Type,
TypeName
, bool> MatchesNameAndAssemblyLessVersionData() => new()
18
{ typeof(int),
TypeName
.Parse(typeof(int).AssemblyQualifiedName), false },
19
{ typeof(int),
TypeName
.Parse($"System.Int32, {Mscorlib}"), true },
20
{ typeof(int?),
TypeName
.Parse($"System.Int32, {Mscorlib}"), true },
21
{ typeof(int?[]),
TypeName
.Parse($"System.Nullable`1[[System.Int32, {Mscorlib}]][], {Mscorlib}"), true},
22
{ typeof(DayOfWeek),
TypeName
.Parse($"System.Nullable`1[[System.DayOfWeek, {Mscorlib}]], {Mscorlib}"), false },
23
{ typeof(Bitmap),
TypeName
.Parse("System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), true },
25
{ typeof(Bitmap),
TypeName
.Parse("System.Drawing.Bitmap, System.Drawing, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), true },
27
{ typeof(Bitmap),
TypeName
.Parse("System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f1AAAAAAA"), false },
29
{ typeof(Bitmap),
TypeName
.Parse("System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a"), false },
31
{ typeof(Bitmap),
TypeName
.Parse("System.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), false },
32
{ typeof(Bitmap),
TypeName
.Parse("System.Drawing.MyBitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), false },
33
{ typeof(Bitmap?[]),
TypeName
.Parse("System.Drawing.Bitmap[], System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), true },
34
{ typeof(Dictionary<string, Bitmap>),
TypeName
.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Mscorlib}"), true },
35
{ typeof(Dictionary<string, Bitmap?>),
TypeName
.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Mscorlib}"), true },
36
{ typeof(NonForwardedType),
TypeName
.Parse("System.Windows.Forms.Tests.TypeExtensionsTests.NonForwardedType"), false },
38
{ typeof(NonForwardedType),
TypeName
.Parse("System.Windows.Forms.Tests.TypeExtensionstests+NonForwardedType"), false },
40
{ typeof(NonForwardedType),
TypeName
.Parse("System.Windows.Forms.Tests.TypeExtensionsTests+NonForwardedType"), false },
41
{ typeof(NonForwardedType),
TypeName
.Parse("System.Windows.Forms.Tests.TypeExtensionsTests+NonForwardedType, System.Windows.Forms.Tests"), false },
43
{ typeof(NonForwardedType),
TypeName
.Parse("System.Windows.Forms.Tests.TypeExtensionsTests+NonForwardedType, System.windows.Forms.Tests, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"), true },
45
{ typeof(NonForwardedType),
TypeName
.Parse("System.Windows.Forms.Tests.typeExtensionsTests+NonForwardedType, System.Windows.Forms.Tests"), false },
46
{ typeof(ForwardedType),
TypeName
.Parse("System.Windows.Forms.Tests.TypeExtensionsTests+ForwardedType, Abc"), true },
51
public void MatchesLessAssemblyVersion(Type type,
TypeName
typeName, bool matches) =>
55
public static TheoryData<
TypeName
,
TypeName
, bool> MatchesTypeNameData() => new()
57
{
TypeName
.Parse($"System.Int32, {Mscorlib}"),
TypeName
.Parse($"System.Int32, {Mscorlib}"), true },
58
{
TypeName
.Parse($"System.Int32, {Mscorlib}"),
TypeName
.Parse($"System.String, {Mscorlib}"), false },
59
{
TypeName
.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Mscorlib}"),
TypeName
.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Mscorlib}"), true },
60
{
TypeName
.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Mscorlib}"),
TypeName
.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Mscorlib}"), false },
61
{
TypeName
.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {Mscorlib}],[System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], {Mscorlib}"),
TypeName
.Parse($"System.Collections.Generic.Dictionary`2[[System.String, {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 },
62
{
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 },
63
{
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 },
64
{
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 },
65
{
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 },
70
public void Matches_TypeName(
TypeName
x,
TypeName
y, bool matches) =>
105
TypeName
name = typeof(ForwardedType).ToTypeName();
System\Windows\Forms\TypeNameComparerTests.cs (42)
14
public static TheoryData<
TypeName
, Type> TypeNameComparerSuccess() => new()
16
{
TypeName
.Parse(typeof(int).AssemblyQualifiedName), typeof(int) },
17
{
TypeName
.Parse($"{typeof(int).FullName}, {typeof(int).Assembly.FullName}"), typeof(int) },
18
{
TypeName
.Parse(typeof(int[]).AssemblyQualifiedName), typeof(int[]) },
19
{
TypeName
.Parse($"{typeof(int[]).FullName}, {typeof(int[]).Assembly.FullName}"), typeof(int[]) },
20
{
TypeName
.Parse(typeof(List<int>).AssemblyQualifiedName), typeof(List<int>) },
21
{
TypeName
.Parse($"{typeof(List<int>).FullName}, {typeof(List<int>).Assembly.FullName}"), typeof(List<int>) },
22
{
TypeName
.Parse(typeof(TestType).AssemblyQualifiedName), typeof(TestType) },
23
{
TypeName
.Parse($"{typeof(TestType).FullName}, {typeof(TestType).Assembly.FullName}"), typeof(TestType) },
28
public void DictionaryLookupSucceeds(
TypeName
name, Type expected)
30
Dictionary<
TypeName
, Type> types = new(DataObject.Composition.TypeNameComparer.Default)
32
{
TypeName
.Parse(typeof(int).AssemblyQualifiedName), typeof(int) },
33
{
TypeName
.Parse(typeof(int[]).AssemblyQualifiedName), typeof(int[]) },
34
{
TypeName
.Parse(typeof(List<int>).AssemblyQualifiedName), typeof(List<int>) },
35
{
TypeName
.Parse(typeof(TestType).AssemblyQualifiedName), typeof(TestType) },
42
public static TheoryData<
TypeName
> TypeNameComparerFail() =>
44
TypeName
.Parse("System.Int32[], System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"),
45
TypeName
.Parse("System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"),
46
TypeName
.Parse("System.Int32, System.Private.CoreLib, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"),
47
TypeName
.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}"),
48
TypeName
.Parse($"{typeof(TestType).FullName}, {typeof(int).Assembly.FullName}")
53
public void DictionaryLookupVersionMismatch(
TypeName
name)
55
Dictionary<
TypeName
, Type> types = new(DataObject.Composition.TypeNameComparer.Default)
57
{
TypeName
.Parse(typeof(int).AssemblyQualifiedName), typeof(int) },
58
{
TypeName
.Parse(typeof(int[]).AssemblyQualifiedName), typeof(int[]) },
59
{
TypeName
.Parse(typeof(List<int>).AssemblyQualifiedName), typeof(List<int>) },
60
{
TypeName
.Parse(typeof(TestType).AssemblyQualifiedName), typeof(TestType) },
69
Dictionary<
TypeName
, Type> types = new(DataObject.Composition.TypeNameComparer.Default)
71
{
TypeName
.Parse(typeof(int).AssemblyQualifiedName), typeof(int) },
72
{
TypeName
.Parse(typeof(int[]).AssemblyQualifiedName), typeof(int[]) },
73
{
TypeName
.Parse(typeof(List<int>).AssemblyQualifiedName), typeof(List<int>) },
74
{
TypeName
.Parse(typeof(TestType).AssemblyQualifiedName), typeof(TestType) },
77
TypeName
name =
TypeName
.Parse(typeof(int).AssemblyQualifiedName);
80
name =
TypeName
.Parse(testName);
90
comparer.Equals(null,
TypeName
.Parse(typeof(int).AssemblyQualifiedName)).Should().BeFalse();
91
comparer.Equals(
TypeName
.Parse(typeof(int).AssemblyQualifiedName), null).Should().BeFalse();
93
TypeName
.Parse(typeof(int).AssemblyQualifiedName),
94
TypeName
.Parse($"{typeof(int).FullName}, {typeof(int).Assembly.FullName}")).Should().BeTrue();
102
int hash = comparer.GetHashCode(
TypeName
.Parse(typeof(int).AssemblyQualifiedName));
103
comparer.GetHashCode(
TypeName
.Parse(typeof(int).AssemblyQualifiedName)).Should().Be(hash);
104
comparer.GetHashCode(
TypeName
.Parse($"{typeof(int).FullName}, {typeof(int).Assembly.FullName}")).Should().Be(hash);