Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TypeDescriptor.cs
Go to the documentation of this file.
8
10
11public sealed class TypeDescriptor
12{
14 {
16 {
18
19 private readonly object _instance;
20
21 internal ComNativeTypeDescriptor(IComNativeDescriptorHandler handler, object instance)
22 {
23 _handler = handler;
24 _instance = instance;
25 }
26
31
36
38 {
39 return null;
40 }
41
42 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
47
48 [RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
53
54 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
59
60 [RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
61 object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
62 {
63 return _handler.GetEditor(_instance, editorBaseType);
64 }
65
70
71 [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
76
77 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
82
83 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
88
93 }
94
95 internal IComNativeDescriptorHandler Handler { get; set; }
96
98 {
99 Handler = handler;
100 }
101
102 [return: NotNullIfNotNull("instance")]
103 public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
104 {
105 if (objectType == null)
106 {
107 throw new ArgumentNullException("objectType");
108 }
109 if (instance == null)
110 {
111 return null;
112 }
113 if (!objectType.IsInstanceOfType(instance))
114 {
115 throw new ArgumentException(System.SR.Format(System.SR.ConvertToException, "objectType", instance.GetType()), "instance");
116 }
117 return new ComNativeTypeDescriptor(Handler, instance);
118 }
119 }
120
122 {
124 {
125 private readonly Attribute[] _attributeArray;
126
128 : base(parent)
129 {
130 _attributeArray = attrs;
131 }
132
134 {
135 Attribute[] array = null;
136 AttributeCollection attributes = base.GetAttributes();
137 Attribute[] attributeArray = _attributeArray;
138 Attribute[] array2 = new Attribute[attributes.Count + attributeArray.Length];
139 int count = attributes.Count;
140 attributes.CopyTo(array2, 0);
141 for (int i = 0; i < attributeArray.Length; i++)
142 {
143 bool flag = false;
144 for (int j = 0; j < attributes.Count; j++)
145 {
146 if (array2[j].TypeId.Equals(attributeArray[i].TypeId))
147 {
148 flag = true;
149 array2[j] = attributeArray[i];
150 break;
151 }
152 }
153 if (!flag)
154 {
155 array2[count++] = attributeArray[i];
156 }
157 }
158 if (count < array2.Length)
159 {
160 array = new Attribute[count];
161 Array.Copy(array2, array, count);
162 }
163 else
164 {
165 array = array2;
166 }
167 return new AttributeCollection(array);
168 }
169 }
170
171 private readonly Attribute[] _attrs;
172
173 internal AttributeProvider(TypeDescriptionProvider existingProvider, params Attribute[] attrs)
174 : base(existingProvider)
175 {
176 _attrs = attrs;
177 }
178
179 public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
180 {
181 return new AttributeTypeDescriptor(_attrs, base.GetTypeDescriptor(objectType, instance));
182 }
183 }
184
185 private sealed class AttributeFilterCacheItem
186 {
187 private readonly Attribute[] _filter;
188
189 internal readonly ICollection FilteredMembers;
190
191 internal AttributeFilterCacheItem(Attribute[] filter, ICollection filteredMembers)
192 {
193 _filter = filter;
194 FilteredMembers = filteredMembers;
195 }
196
197 internal bool IsValid(Attribute[] filter)
198 {
199 if (_filter.Length != filter.Length)
200 {
201 return false;
202 }
203 for (int i = 0; i < filter.Length; i++)
204 {
205 if (_filter[i] != filter[i])
206 {
207 return false;
208 }
209 }
210 return true;
211 }
212 }
213
214 private sealed class FilterCacheItem
215 {
217
218 internal readonly ICollection FilteredMembers;
219
220 internal FilterCacheItem(ITypeDescriptorFilterService filterService, ICollection filteredMembers)
221 {
222 _filterService = filterService;
223 FilteredMembers = filteredMembers;
224 }
225
226 internal bool IsValid(ITypeDescriptorFilterService filterService)
227 {
228 if (_filterService != filterService)
229 {
230 return false;
231 }
232 return true;
233 }
234 }
235
236 private sealed class MemberDescriptorComparer : IComparer
237 {
239
240 public int Compare(object left, object right)
241 {
242 return CultureInfo.InvariantCulture.CompareInfo.Compare((left as MemberDescriptor)?.Name, (right as MemberDescriptor)?.Name);
243 }
244 }
245
246 [TypeDescriptionProvider(typeof(ComNativeDescriptorProxy))]
247 private sealed class TypeDescriptorComObject
248 {
249 }
250
252 {
254
255 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:UnrecognizedReflectionPattern", Justification = "The trimmer can't find the ComNativeDescriptor type when System.Windows.Forms isn't available. When System.Windows.Forms is available, the type will be seen by the trimmer and the ctor will be preserved.")]
257 {
258 Type type = Type.GetType("System.Windows.Forms.ComponentModel.Com2Interop.ComNativeDescriptor, System.Windows.Forms", throwOnError: true);
260 }
261
262 [return: NotNullIfNotNull("instance")]
263 public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
264 {
265 return _comNativeDescriptor.GetTypeDescriptor(objectType, instance);
266 }
267 }
268
270 {
272
274
276 {
277 _primary = primary;
278 _secondary = secondary;
279 }
280
285
290
295
296 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
301
302 [RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
307
308 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
313
314 [RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
315 object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
316 {
317 if (editorBaseType == null)
318 {
319 throw new ArgumentNullException("editorBaseType");
320 }
321 return _primary.GetEditor(editorBaseType) ?? _secondary.GetEditor(editorBaseType);
322 }
323
328
329 [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
331 {
332 return _primary.GetEvents(attributes) ?? _secondary.GetEvents(attributes);
333 }
334
335 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
340
341 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
343 {
344 PropertyDescriptorCollection properties = _primary.GetProperties(attributes);
345 if (properties == null)
346 {
347 properties = _secondary.GetProperties(attributes);
348 }
349 return properties;
350 }
351
356 }
357
359 {
361 {
362 private readonly TypeDescriptionNode _node;
363
364 private readonly object _instance;
365
366 [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
368 {
369 _node = node;
370 _instance = instance;
371 }
372
373 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
375 {
377 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
378 {
379 return reflectTypeDescriptionProvider.GetExtendedAttributes(_instance);
380 }
381 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
382 if (extendedTypeDescriptor == null)
383 {
384 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
385 }
386 AttributeCollection attributes = extendedTypeDescriptor.GetAttributes();
387 if (attributes == null)
388 {
389 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetAttributes"));
390 }
391 return attributes;
392 }
393
394 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
396 {
398 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
399 {
400 return reflectTypeDescriptionProvider.GetExtendedClassName(_instance);
401 }
402 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
403 if (extendedTypeDescriptor == null)
404 {
405 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
406 }
407 return extendedTypeDescriptor.GetClassName() ?? _instance.GetType().FullName;
408 }
409
410 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
412 {
414 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
415 {
416 return reflectTypeDescriptionProvider.GetExtendedComponentName(_instance);
417 }
418 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
419 if (extendedTypeDescriptor == null)
420 {
421 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
422 }
423 return extendedTypeDescriptor.GetComponentName();
424 }
425
426 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
428 {
430 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
431 {
432 return reflectTypeDescriptionProvider.GetExtendedConverter(_instance);
433 }
434 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
435 if (extendedTypeDescriptor == null)
436 {
437 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
438 }
439 TypeConverter converter = extendedTypeDescriptor.GetConverter();
440 if (converter == null)
441 {
442 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetConverter"));
443 }
444 return converter;
445 }
446
447 [RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
449 {
451 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
452 {
453 return reflectTypeDescriptionProvider.GetExtendedDefaultEvent(_instance);
454 }
455 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
456 if (extendedTypeDescriptor == null)
457 {
458 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
459 }
460 return extendedTypeDescriptor.GetDefaultEvent();
461 }
462
463 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
465 {
467 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
468 {
469 return reflectTypeDescriptionProvider.GetExtendedDefaultProperty(_instance);
470 }
471 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
472 if (extendedTypeDescriptor == null)
473 {
474 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
475 }
476 return extendedTypeDescriptor.GetDefaultProperty();
477 }
478
479 [RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
480 object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
481 {
482 if (editorBaseType == null)
483 {
484 throw new ArgumentNullException("editorBaseType");
485 }
487 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
488 {
489 return reflectTypeDescriptionProvider.GetExtendedEditor(_instance, editorBaseType);
490 }
491 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
492 if (extendedTypeDescriptor == null)
493 {
494 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
495 }
496 return extendedTypeDescriptor.GetEditor(editorBaseType);
497 }
498
499 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
501 {
503 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
504 {
505 return reflectTypeDescriptionProvider.GetExtendedEvents(_instance);
506 }
507 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
508 if (extendedTypeDescriptor == null)
509 {
510 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
511 }
512 EventDescriptorCollection events = extendedTypeDescriptor.GetEvents();
513 if (events == null)
514 {
515 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetEvents"));
516 }
517 return events;
518 }
519
520 [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
522 {
524 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
525 {
526 return reflectTypeDescriptionProvider.GetExtendedEvents(_instance);
527 }
528 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
529 if (extendedTypeDescriptor == null)
530 {
531 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
532 }
533 EventDescriptorCollection events = extendedTypeDescriptor.GetEvents(attributes);
534 if (events == null)
535 {
536 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetEvents"));
537 }
538 return events;
539 }
540
541 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
543 {
545 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
546 {
547 return reflectTypeDescriptionProvider.GetExtendedProperties(_instance);
548 }
549 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
550 if (extendedTypeDescriptor == null)
551 {
552 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
553 }
554 PropertyDescriptorCollection properties = extendedTypeDescriptor.GetProperties();
555 if (properties == null)
556 {
557 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetProperties"));
558 }
559 return properties;
560 }
561
562 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
564 {
566 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
567 {
568 return reflectTypeDescriptionProvider.GetExtendedProperties(_instance);
569 }
570 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
571 if (extendedTypeDescriptor == null)
572 {
573 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
574 }
575 PropertyDescriptorCollection properties = extendedTypeDescriptor.GetProperties(attributes);
576 if (properties == null)
577 {
578 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetProperties"));
579 }
580 return properties;
581 }
582
583 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor of this Type has RequiresUnreferencedCode.")]
585 {
587 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
588 {
589 return reflectTypeDescriptionProvider.GetExtendedPropertyOwner(_instance, pd);
590 }
591 ICustomTypeDescriptor extendedTypeDescriptor = provider.GetExtendedTypeDescriptor(_instance);
592 if (extendedTypeDescriptor == null)
593 {
594 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
595 }
596 return extendedTypeDescriptor.GetPropertyOwner(pd) ?? _instance;
597 }
598 }
599
601 {
602 private readonly TypeDescriptionNode _node;
603
604 [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
605 private readonly Type _objectType;
606
607 private readonly object _instance;
608
609 internal DefaultTypeDescriptor(TypeDescriptionNode node, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
610 {
611 _node = node;
612 _objectType = objectType;
613 _instance = instance;
614 }
615
617 {
619 AttributeCollection attributes;
620 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
621 {
622 attributes = reflectTypeDescriptionProvider.GetAttributes(_objectType);
623 }
624 else
625 {
627 if (typeDescriptor == null)
628 {
629 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
630 }
631 attributes = typeDescriptor.GetAttributes();
632 if (attributes == null)
633 {
634 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetAttributes"));
635 }
636 }
637 return attributes;
638 }
639
641 {
643 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
644 {
645 return reflectTypeDescriptionProvider.GetClassName(_objectType);
646 }
648 if (typeDescriptor == null)
649 {
650 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
651 }
652 return typeDescriptor.GetClassName() ?? _objectType.FullName;
653 }
654
656 {
658 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
659 {
660 return reflectTypeDescriptionProvider.GetComponentName(_objectType, _instance);
661 }
663 if (typeDescriptor == null)
664 {
665 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
666 }
667 return typeDescriptor.GetComponentName();
668 }
669
670 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
672 {
675 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
676 {
677 converter = reflectTypeDescriptionProvider.GetConverter(_objectType, _instance);
678 }
679 else
680 {
682 if (typeDescriptor == null)
683 {
684 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
685 }
686 converter = typeDescriptor.GetConverter();
687 if (converter == null)
688 {
689 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetConverter"));
690 }
691 }
692 return converter;
693 }
694
695 [RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
697 {
699 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
700 {
701 return reflectTypeDescriptionProvider.GetDefaultEvent(_objectType, _instance);
702 }
704 if (typeDescriptor == null)
705 {
706 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
707 }
708 return typeDescriptor.GetDefaultEvent();
709 }
710
711 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
713 {
715 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
716 {
717 return reflectTypeDescriptionProvider.GetDefaultProperty(_objectType, _instance);
718 }
720 if (typeDescriptor == null)
721 {
722 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
723 }
724 return typeDescriptor.GetDefaultProperty();
725 }
726
727 [RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
728 object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
729 {
730 if (editorBaseType == null)
731 {
732 throw new ArgumentNullException("editorBaseType");
733 }
735 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
736 {
737 return reflectTypeDescriptionProvider.GetEditor(_objectType, _instance, editorBaseType);
738 }
740 if (typeDescriptor == null)
741 {
742 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
743 }
744 return typeDescriptor.GetEditor(editorBaseType);
745 }
746
748 {
751 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
752 {
753 events = reflectTypeDescriptionProvider.GetEvents(_objectType);
754 }
755 else
756 {
758 if (typeDescriptor == null)
759 {
760 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
761 }
762 events = typeDescriptor.GetEvents();
763 if (events == null)
764 {
765 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetEvents"));
766 }
767 }
768 return events;
769 }
770
771 [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
773 {
776 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
777 {
778 events = reflectTypeDescriptionProvider.GetEvents(_objectType);
779 }
780 else
781 {
783 if (typeDescriptor == null)
784 {
785 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
786 }
787 events = typeDescriptor.GetEvents(attributes);
788 if (events == null)
789 {
790 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetEvents"));
791 }
792 }
793 return events;
794 }
795
796 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
798 {
801 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
802 {
803 properties = reflectTypeDescriptionProvider.GetProperties(_objectType);
804 }
805 else
806 {
808 if (typeDescriptor == null)
809 {
810 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
811 }
812 properties = typeDescriptor.GetProperties();
813 if (properties == null)
814 {
815 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetProperties"));
816 }
817 }
818 return properties;
819 }
820
821 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
823 {
826 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
827 {
828 properties = reflectTypeDescriptionProvider.GetProperties(_objectType);
829 }
830 else
831 {
833 if (typeDescriptor == null)
834 {
835 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
836 }
837 properties = typeDescriptor.GetProperties(attributes);
838 if (properties == null)
839 {
840 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetProperties"));
841 }
842 }
843 return properties;
844 }
845
847 {
849 if (provider is ReflectTypeDescriptionProvider reflectTypeDescriptionProvider)
850 {
851 return reflectTypeDescriptionProvider.GetPropertyOwner(_objectType, _instance, pd);
852 }
854 if (typeDescriptor == null)
855 {
856 throw new InvalidOperationException(System.SR.Format(System.SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetTypeDescriptor"));
857 }
858 return typeDescriptor.GetPropertyOwner(pd) ?? _instance;
859 }
860 }
861
863
865
867 {
868 Provider = provider;
869 }
870
871 public override object CreateInstance(IServiceProvider provider, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType, Type[] argTypes, object[] args)
872 {
873 if (objectType == null)
874 {
875 throw new ArgumentNullException("objectType");
876 }
877 if (argTypes != null)
878 {
879 if (args == null)
880 {
881 throw new ArgumentNullException("args");
882 }
883 if (argTypes.Length != args.Length)
884 {
886 }
887 }
888 return Provider.CreateInstance(provider, objectType, argTypes, args);
889 }
890
891 public override IDictionary GetCache(object instance)
892 {
893 if (instance == null)
894 {
895 throw new ArgumentNullException("instance");
896 }
897 return Provider.GetCache(instance);
898 }
899
900 [RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
901 public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
902 {
903 if (instance == null)
904 {
905 throw new ArgumentNullException("instance");
906 }
907 return new DefaultExtendedTypeDescriptor(this, instance);
908 }
909
910 protected internal override IExtenderProvider[] GetExtenderProviders(object instance)
911 {
912 if (instance == null)
913 {
914 throw new ArgumentNullException("instance");
915 }
916 return Provider.GetExtenderProviders(instance);
917 }
918
919 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
920 public override string GetFullComponentName(object component)
921 {
922 if (component == null)
923 {
924 throw new ArgumentNullException("component");
925 }
926 return Provider.GetFullComponentName(component);
927 }
928
929 [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields)]
930 public override Type GetReflectionType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields)] Type objectType, object instance)
931 {
932 if (objectType == null)
933 {
934 throw new ArgumentNullException("objectType");
935 }
936 return Provider.GetReflectionType(objectType, instance);
937 }
938
939 public override Type GetRuntimeType(Type objectType)
940 {
941 if (objectType == null)
942 {
943 throw new ArgumentNullException("objectType");
944 }
945 return Provider.GetRuntimeType(objectType);
946 }
947
948 public override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
949 {
950 if (objectType == null)
951 {
952 throw new ArgumentNullException("objectType");
953 }
954 if (instance != null && !objectType.IsInstanceOfType(instance))
955 {
956 throw new ArgumentException("instance");
957 }
958 return new DefaultTypeDescriptor(this, objectType, instance);
959 }
960
961 public override bool IsSupportedType(Type type)
962 {
963 if (type == null)
964 {
965 throw new ArgumentNullException("type");
966 }
967 return Provider.IsSupportedType(type);
968 }
969 }
970
971 private sealed class TypeDescriptorInterface
972 {
973 }
974
975 private static readonly WeakHashtable s_providerTable = new WeakHashtable();
976
977 private static readonly Hashtable s_providerTypeTable = new Hashtable();
978
979 private static readonly Hashtable s_defaultProviders = new Hashtable();
980
982
983 private static int s_metadataVersion;
984
985 private static int s_collisionIndex;
986
987 private static readonly Guid[] s_pipelineInitializeKeys = new Guid[3]
988 {
989 Guid.NewGuid(),
990 Guid.NewGuid(),
991 Guid.NewGuid()
992 };
993
994 private static readonly Guid[] s_pipelineMergeKeys = new Guid[3]
995 {
996 Guid.NewGuid(),
997 Guid.NewGuid(),
998 Guid.NewGuid()
999 };
1000
1001 private static readonly Guid[] s_pipelineFilterKeys = new Guid[3]
1002 {
1003 Guid.NewGuid(),
1004 Guid.NewGuid(),
1005 Guid.NewGuid()
1006 };
1007
1008 private static readonly Guid[] s_pipelineAttributeFilterKeys = new Guid[3]
1009 {
1010 Guid.NewGuid(),
1011 Guid.NewGuid(),
1012 Guid.NewGuid()
1013 };
1014
1015 private static readonly object s_internalSyncObject = new object();
1016
1017 [EditorBrowsable(EditorBrowsableState.Advanced)]
1018 public static Type InterfaceType
1019 {
1020 [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
1021 get
1022 {
1023 return typeof(TypeDescriptorInterface);
1024 }
1025 }
1026
1027 internal static int MetadataVersion => s_metadataVersion;
1028
1029 private static WeakHashtable AssociationTable => LazyInitializer.EnsureInitialized(ref s_associationTable, () => new WeakHashtable());
1030
1031 [EditorBrowsable(EditorBrowsableState.Advanced)]
1032 public static Type ComObjectType
1033 {
1034 [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
1035 get
1036 {
1037 return typeof(TypeDescriptorComObject);
1038 }
1039 }
1040
1041 [Obsolete("TypeDescriptor.ComNativeDescriptorHandler has been deprecated. Use a type description provider to supply type information for COM types instead.")]
1043 {
1044 get
1045 {
1046 TypeDescriptionNode typeDescriptionNode = NodeFor(ComObjectType);
1047 ComNativeDescriptionProvider comNativeDescriptionProvider;
1048 do
1049 {
1050 comNativeDescriptionProvider = typeDescriptionNode.Provider as ComNativeDescriptionProvider;
1051 typeDescriptionNode = typeDescriptionNode.Next;
1052 }
1053 while (typeDescriptionNode != null && comNativeDescriptionProvider == null);
1054 return comNativeDescriptionProvider?.Handler;
1055 }
1056 [param: DisallowNull]
1057 set
1058 {
1059 TypeDescriptionNode typeDescriptionNode = NodeFor(ComObjectType);
1060 while (typeDescriptionNode != null && !(typeDescriptionNode.Provider is ComNativeDescriptionProvider))
1061 {
1062 typeDescriptionNode = typeDescriptionNode.Next;
1063 }
1064 if (typeDescriptionNode == null)
1065 {
1067 }
1068 else
1069 {
1070 ((ComNativeDescriptionProvider)typeDescriptionNode.Provider).Handler = value;
1071 }
1072 }
1073 }
1074
1075 public static event RefreshEventHandler? Refreshed;
1076
1077 [EditorBrowsable(EditorBrowsableState.Advanced)]
1078 public static TypeDescriptionProvider AddAttributes(Type type, params Attribute[] attributes)
1079 {
1080 if (type == null)
1081 {
1082 throw new ArgumentNullException("type");
1083 }
1084 if (attributes == null)
1085 {
1086 throw new ArgumentNullException("attributes");
1087 }
1089 TypeDescriptionProvider typeDescriptionProvider = new AttributeProvider(provider, attributes);
1090 AddProvider(typeDescriptionProvider, type);
1091 return typeDescriptionProvider;
1092 }
1093
1094 [EditorBrowsable(EditorBrowsableState.Advanced)]
1095 public static TypeDescriptionProvider AddAttributes(object instance, params Attribute[] attributes)
1096 {
1097 if (instance == null)
1098 {
1099 throw new ArgumentNullException("instance");
1100 }
1101 if (attributes == null)
1102 {
1103 throw new ArgumentNullException("attributes");
1104 }
1105 TypeDescriptionProvider provider = GetProvider(instance);
1106 TypeDescriptionProvider typeDescriptionProvider = new AttributeProvider(provider, attributes);
1107 AddProvider(typeDescriptionProvider, instance);
1108 return typeDescriptionProvider;
1109 }
1110
1111 [EditorBrowsable(EditorBrowsableState.Advanced)]
1112 [RequiresUnreferencedCode("The Types specified in table may be trimmed, or have their static construtors trimmed.")]
1113 public static void AddEditorTable(Type editorBaseType, Hashtable table)
1114 {
1115 ReflectTypeDescriptionProvider.AddEditorTable(editorBaseType, table);
1116 }
1117
1118 [EditorBrowsable(EditorBrowsableState.Advanced)]
1119 public static void AddProvider(TypeDescriptionProvider provider, Type type)
1120 {
1121 if (provider == null)
1122 {
1123 throw new ArgumentNullException("provider");
1124 }
1125 if (type == null)
1126 {
1127 throw new ArgumentNullException("type");
1128 }
1129 lock (s_providerTable)
1130 {
1131 TypeDescriptionNode next = NodeFor(type, createDelegator: true);
1133 {
1134 Next = next
1135 };
1137 s_providerTypeTable.Clear();
1138 }
1139 Refresh(type);
1140 }
1141
1142 [EditorBrowsable(EditorBrowsableState.Advanced)]
1143 public static void AddProvider(TypeDescriptionProvider provider, object instance)
1144 {
1145 if (provider == null)
1146 {
1147 throw new ArgumentNullException("provider");
1148 }
1149 if (instance == null)
1150 {
1151 throw new ArgumentNullException("instance");
1152 }
1153 bool flag;
1154 lock (s_providerTable)
1155 {
1156 flag = s_providerTable.ContainsKey(instance);
1157 TypeDescriptionNode next = NodeFor(instance, createDelegator: true);
1159 {
1160 Next = next
1161 };
1162 s_providerTable.SetWeak(instance, value);
1163 s_providerTypeTable.Clear();
1164 }
1165 if (flag)
1166 {
1167 Refresh(instance, refreshReflectionProvider: false);
1168 }
1169 }
1170
1171 [EditorBrowsable(EditorBrowsableState.Advanced)]
1173 {
1174 if (provider == null)
1175 {
1176 throw new ArgumentNullException("provider");
1177 }
1178 if (type == null)
1179 {
1180 throw new ArgumentNullException("type");
1181 }
1182 AddProvider(provider, type);
1183 }
1184
1185 [EditorBrowsable(EditorBrowsableState.Advanced)]
1186 public static void AddProviderTransparent(TypeDescriptionProvider provider, object instance)
1187 {
1188 if (provider == null)
1189 {
1190 throw new ArgumentNullException("provider");
1191 }
1192 if (instance == null)
1193 {
1194 throw new ArgumentNullException("instance");
1195 }
1196 AddProvider(provider, instance);
1197 }
1198
1199 private static void CheckDefaultProvider(Type type)
1200 {
1201 if (s_defaultProviders.ContainsKey(type))
1202 {
1203 return;
1204 }
1206 {
1207 if (s_defaultProviders.ContainsKey(type))
1208 {
1209 return;
1210 }
1211 s_defaultProviders[type] = null;
1212 }
1213 object[] customAttributes = type.GetCustomAttributes(typeof(TypeDescriptionProviderAttribute), inherit: false);
1214 bool flag = false;
1215 for (int num = customAttributes.Length - 1; num >= 0; num--)
1216 {
1217 TypeDescriptionProviderAttribute typeDescriptionProviderAttribute = (TypeDescriptionProviderAttribute)customAttributes[num];
1218 Type type2 = Type.GetType(typeDescriptionProviderAttribute.TypeName);
1219 if (type2 != null && typeof(TypeDescriptionProvider).IsAssignableFrom(type2))
1220 {
1222 AddProvider(provider, type);
1223 flag = true;
1224 }
1225 }
1226 if (!flag)
1227 {
1228 Type baseType = type.BaseType;
1229 if (baseType != null && baseType != type)
1230 {
1231 CheckDefaultProvider(baseType);
1232 }
1233 }
1234 }
1235
1236 [EditorBrowsable(EditorBrowsableState.Advanced)]
1237 public static void CreateAssociation(object primary, object secondary)
1238 {
1239 if (primary == null)
1240 {
1241 throw new ArgumentNullException("primary");
1242 }
1243 if (secondary == null)
1244 {
1245 throw new ArgumentNullException("secondary");
1246 }
1247 if (primary == secondary)
1248 {
1250 }
1251 WeakHashtable associationTable = AssociationTable;
1252 IList list = (IList)associationTable[primary];
1253 if (list == null)
1254 {
1255 lock (associationTable)
1256 {
1257 list = (IList)associationTable[primary];
1258 if (list == null)
1259 {
1260 list = new ArrayList(4);
1261 associationTable.SetWeak(primary, list);
1262 }
1263 }
1264 }
1265 else
1266 {
1267 for (int num = list.Count - 1; num >= 0; num--)
1268 {
1269 WeakReference weakReference = (WeakReference)list[num];
1270 if (weakReference.IsAlive && weakReference.Target == secondary)
1271 {
1273 }
1274 }
1275 }
1276 lock (list)
1277 {
1278 list.Add(new WeakReference(secondary));
1279 }
1280 }
1281
1282 public static EventDescriptor CreateEvent([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, string name, Type type, params Attribute[] attributes)
1283 {
1284 return new ReflectEventDescriptor(componentType, name, type, attributes);
1285 }
1286
1287 public static EventDescriptor CreateEvent([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, EventDescriptor oldEventDescriptor, params Attribute[] attributes)
1288 {
1289 return new ReflectEventDescriptor(componentType, oldEventDescriptor, attributes);
1290 }
1291
1292 public static object? CreateInstance(IServiceProvider? provider, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType, Type[]? argTypes, object[]? args)
1293 {
1294 if (objectType == null)
1295 {
1296 throw new ArgumentNullException("objectType");
1297 }
1298 if (argTypes != null)
1299 {
1300 if (args == null)
1301 {
1302 throw new ArgumentNullException("args");
1303 }
1304 if (argTypes.Length != args.Length)
1305 {
1307 }
1308 }
1309 object obj = null;
1310 if (provider?.GetService(typeof(TypeDescriptionProvider)) is TypeDescriptionProvider typeDescriptionProvider)
1311 {
1312 obj = typeDescriptionProvider.CreateInstance(provider, objectType, argTypes, args);
1313 }
1314 return obj ?? NodeFor(objectType).CreateInstance(provider, objectType, argTypes, args);
1315 }
1316
1317 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
1318 public static PropertyDescriptor CreateProperty([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, string name, Type type, params Attribute[] attributes)
1319 {
1320 return new ReflectPropertyDescriptor(componentType, name, type, attributes);
1321 }
1322
1323 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
1324 public static PropertyDescriptor CreateProperty([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, PropertyDescriptor oldPropertyDescriptor, params Attribute[] attributes)
1325 {
1326 if (componentType == oldPropertyDescriptor.ComponentType)
1327 {
1328 ExtenderProvidedPropertyAttribute extenderProvidedPropertyAttribute = (ExtenderProvidedPropertyAttribute)oldPropertyDescriptor.Attributes[typeof(ExtenderProvidedPropertyAttribute)];
1329 if (extenderProvidedPropertyAttribute.ExtenderProperty is ReflectPropertyDescriptor)
1330 {
1331 return new ExtendedPropertyDescriptor(oldPropertyDescriptor, attributes);
1332 }
1333 }
1334 return new ReflectPropertyDescriptor(componentType, oldPropertyDescriptor, attributes);
1335 }
1336
1337 [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
1338 private static ArrayList FilterMembers(IList members, Attribute[] attributes)
1339 {
1340 ArrayList arrayList = null;
1341 int count = members.Count;
1342 for (int i = 0; i < count; i++)
1343 {
1344 bool flag = false;
1345 for (int j = 0; j < attributes.Length; j++)
1346 {
1347 if (ShouldHideMember((MemberDescriptor)members[i], attributes[j]))
1348 {
1349 flag = true;
1350 break;
1351 }
1352 }
1353 if (flag)
1354 {
1355 if (arrayList == null)
1356 {
1357 arrayList = new ArrayList(count);
1358 for (int k = 0; k < i; k++)
1359 {
1360 arrayList.Add(members[k]);
1361 }
1362 }
1363 }
1364 else
1365 {
1366 arrayList?.Add(members[i]);
1367 }
1368 }
1369 return arrayList;
1370 }
1371
1372 [EditorBrowsable(EditorBrowsableState.Advanced)]
1373 public static object GetAssociation(Type type, object primary)
1374 {
1375 if (type == null)
1376 {
1377 throw new ArgumentNullException("type");
1378 }
1379 if (primary == null)
1380 {
1381 throw new ArgumentNullException("primary");
1382 }
1383 object obj = primary;
1384 if (!type.IsInstanceOfType(primary))
1385 {
1386 IList list = (IList)(AssociationTable?[primary]);
1387 if (list != null)
1388 {
1389 lock (list)
1390 {
1391 for (int num = list.Count - 1; num >= 0; num--)
1392 {
1393 WeakReference weakReference = (WeakReference)list[num];
1394 object target = weakReference.Target;
1395 if (target == null)
1396 {
1397 list.RemoveAt(num);
1398 }
1399 else if (type.IsInstanceOfType(target))
1400 {
1401 obj = target;
1402 }
1403 }
1404 }
1405 }
1406 if (obj == primary && primary is IComponent component)
1407 {
1408 ISite site = component.Site;
1409 if (site != null && site.DesignMode && site.GetService(typeof(IDesignerHost)) is IDesignerHost designerHost)
1410 {
1411 object designer = designerHost.GetDesigner(component);
1412 if (designer != null && type.IsInstanceOfType(designer))
1413 {
1414 obj = designer;
1415 }
1416 }
1417 }
1418 }
1419 return obj;
1420 }
1421
1422 public static AttributeCollection GetAttributes([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
1423 {
1424 if (componentType == null)
1425 {
1426 return new AttributeCollection((Attribute[]?)null);
1427 }
1428 return GetDescriptor(componentType, "componentType").GetAttributes();
1429 }
1430
1431 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1432 public static AttributeCollection GetAttributes(object component)
1433 {
1434 return GetAttributes(component, noCustomTypeDesc: false);
1435 }
1436
1437 [EditorBrowsable(EditorBrowsableState.Advanced)]
1438 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1439 public static AttributeCollection GetAttributes(object component, bool noCustomTypeDesc)
1440 {
1441 if (component == null)
1442 {
1443 return new AttributeCollection((Attribute[]?)null);
1444 }
1445 ICustomTypeDescriptor descriptor = GetDescriptor(component, noCustomTypeDesc);
1446 ICollection collection = descriptor.GetAttributes();
1447 if (component is ICustomTypeDescriptor)
1448 {
1449 if (noCustomTypeDesc)
1450 {
1451 ICustomTypeDescriptor extendedDescriptor = GetExtendedDescriptor(component);
1452 if (extendedDescriptor != null)
1453 {
1454 ICollection attributes = extendedDescriptor.GetAttributes();
1455 collection = PipelineMerge(0, collection, attributes, component, null);
1456 }
1457 }
1458 else
1459 {
1460 collection = PipelineFilter(0, collection, component, null);
1461 }
1462 }
1463 else
1464 {
1465 IDictionary cache = GetCache(component);
1467 ICustomTypeDescriptor extendedDescriptor2 = GetExtendedDescriptor(component);
1468 if (extendedDescriptor2 != null)
1469 {
1470 ICollection attributes2 = extendedDescriptor2.GetAttributes();
1471 collection = PipelineMerge(0, collection, attributes2, component, cache);
1472 }
1473 collection = PipelineFilter(0, collection, component, cache);
1474 }
1475 AttributeCollection attributeCollection = collection as AttributeCollection;
1476 if (attributeCollection == null)
1477 {
1478 Attribute[] array = new Attribute[collection.Count];
1479 collection.CopyTo(array, 0);
1480 attributeCollection = new AttributeCollection(array);
1481 }
1482 return attributeCollection;
1483 }
1484
1485 internal static IDictionary GetCache(object instance)
1486 {
1487 return NodeFor(instance).GetCache(instance);
1488 }
1489
1490 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1491 public static string? GetClassName(object component)
1492 {
1493 return GetClassName(component, noCustomTypeDesc: false);
1494 }
1495
1496 [EditorBrowsable(EditorBrowsableState.Advanced)]
1497 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1498 public static string? GetClassName(object component, bool noCustomTypeDesc)
1499 {
1500 return GetDescriptor(component, noCustomTypeDesc).GetClassName();
1501 }
1502
1503 public static string? GetClassName([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
1504 {
1505 return GetDescriptor(componentType, "componentType").GetClassName();
1506 }
1507
1508 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1509 public static string? GetComponentName(object component)
1510 {
1511 return GetComponentName(component, noCustomTypeDesc: false);
1512 }
1513
1514 [EditorBrowsable(EditorBrowsableState.Advanced)]
1515 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1516 public static string? GetComponentName(object component, bool noCustomTypeDesc)
1517 {
1518 return GetDescriptor(component, noCustomTypeDesc).GetComponentName();
1519 }
1520
1521 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All. The Type of component cannot be statically discovered.")]
1522 public static TypeConverter GetConverter(object component)
1523 {
1524 return GetConverter(component, noCustomTypeDesc: false);
1525 }
1526
1527 [EditorBrowsable(EditorBrowsableState.Advanced)]
1528 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All. The Type of component cannot be statically discovered.")]
1529 public static TypeConverter GetConverter(object component, bool noCustomTypeDesc)
1530 {
1531 return GetDescriptor(component, noCustomTypeDesc).GetConverter();
1532 }
1533
1534 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
1535 public static TypeConverter GetConverter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
1536 {
1537 return GetDescriptor(type, "type").GetConverter();
1538 }
1539
1540 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The callers of this method ensure getting the converter is trim compatible - i.e. the type is not Nullable<T>.")]
1541 internal static TypeConverter GetConverterTrimUnsafe([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
1542 {
1543 return GetConverter(type);
1544 }
1545
1546 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
1547 private static object ConvertFromInvariantString([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, string stringValue)
1548 {
1549 return GetConverter(type).ConvertFromInvariantString(stringValue);
1550 }
1551
1552 [RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
1553 public static EventDescriptor? GetDefaultEvent([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
1554 {
1555 if (componentType == null)
1556 {
1557 return null;
1558 }
1559 return GetDescriptor(componentType, "componentType").GetDefaultEvent();
1560 }
1561
1562 [RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code. The Type of component cannot be statically discovered.")]
1563 public static EventDescriptor? GetDefaultEvent(object component)
1564 {
1565 return GetDefaultEvent(component, noCustomTypeDesc: false);
1566 }
1567
1568 [EditorBrowsable(EditorBrowsableState.Advanced)]
1569 [RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code. The Type of component cannot be statically discovered.")]
1570 public static EventDescriptor? GetDefaultEvent(object component, bool noCustomTypeDesc)
1571 {
1572 if (component == null)
1573 {
1574 return null;
1575 }
1576 return GetDescriptor(component, noCustomTypeDesc).GetDefaultEvent();
1577 }
1578
1579 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
1580 public static PropertyDescriptor? GetDefaultProperty([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
1581 {
1582 if (componentType == null)
1583 {
1584 return null;
1585 }
1586 return GetDescriptor(componentType, "componentType").GetDefaultProperty();
1587 }
1588
1589 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered.")]
1590 public static PropertyDescriptor? GetDefaultProperty(object component)
1591 {
1592 return GetDefaultProperty(component, noCustomTypeDesc: false);
1593 }
1594
1595 [EditorBrowsable(EditorBrowsableState.Advanced)]
1596 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered.")]
1597 public static PropertyDescriptor? GetDefaultProperty(object component, bool noCustomTypeDesc)
1598 {
1599 if (component == null)
1600 {
1601 return null;
1602 }
1603 return GetDescriptor(component, noCustomTypeDesc).GetDefaultProperty();
1604 }
1605
1606 internal static ICustomTypeDescriptor GetDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, string typeName)
1607 {
1608 if (type == null)
1609 {
1610 throw new ArgumentNullException(typeName);
1611 }
1612 return NodeFor(type).GetTypeDescriptor(type);
1613 }
1614
1615 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1616 internal static ICustomTypeDescriptor GetDescriptor(object component, bool noCustomTypeDesc)
1617 {
1618 if (component == null)
1619 {
1620 throw new ArgumentException("component");
1621 }
1622 ICustomTypeDescriptor customTypeDescriptor = NodeFor(component).GetTypeDescriptor(component);
1623 ICustomTypeDescriptor customTypeDescriptor2 = component as ICustomTypeDescriptor;
1624 if (!noCustomTypeDesc && customTypeDescriptor2 != null)
1625 {
1626 customTypeDescriptor = new MergedTypeDescriptor(customTypeDescriptor2, customTypeDescriptor);
1627 }
1628 return customTypeDescriptor;
1629 }
1630
1631 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1632 internal static ICustomTypeDescriptor GetExtendedDescriptor(object component)
1633 {
1634 if (component == null)
1635 {
1636 throw new ArgumentException("component");
1637 }
1638 return NodeFor(component).GetExtendedTypeDescriptor(component);
1639 }
1640
1641 [RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed. The Type of component cannot be statically discovered.")]
1642 public static object? GetEditor(object component, Type editorBaseType)
1643 {
1644 return GetEditor(component, editorBaseType, noCustomTypeDesc: false);
1645 }
1646
1647 [EditorBrowsable(EditorBrowsableState.Advanced)]
1648 [RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed. The Type of component cannot be statically discovered.")]
1649 public static object? GetEditor(object component, Type editorBaseType, bool noCustomTypeDesc)
1650 {
1651 if (editorBaseType == null)
1652 {
1653 throw new ArgumentNullException("editorBaseType");
1654 }
1655 return GetDescriptor(component, noCustomTypeDesc).GetEditor(editorBaseType);
1656 }
1657
1658 [RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
1659 public static object? GetEditor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, Type editorBaseType)
1660 {
1661 if (editorBaseType == null)
1662 {
1663 throw new ArgumentNullException("editorBaseType");
1664 }
1665 return GetDescriptor(type, "type").GetEditor(editorBaseType);
1666 }
1667
1668 public static EventDescriptorCollection GetEvents([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
1669 {
1670 if (componentType == null)
1671 {
1672 return new EventDescriptorCollection(null, readOnly: true);
1673 }
1674 return GetDescriptor(componentType, "componentType").GetEvents();
1675 }
1676
1677 [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
1678 public static EventDescriptorCollection GetEvents([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, Attribute[] attributes)
1679 {
1680 if (componentType == null)
1681 {
1682 return new EventDescriptorCollection(null, readOnly: true);
1683 }
1684 EventDescriptorCollection eventDescriptorCollection = GetDescriptor(componentType, "componentType").GetEvents(attributes);
1685 if (attributes != null && attributes.Length != 0)
1686 {
1687 ArrayList arrayList = FilterMembers(eventDescriptorCollection, attributes);
1688 if (arrayList != null)
1689 {
1690 EventDescriptor[] array = new EventDescriptor[arrayList.Count];
1691 arrayList.CopyTo(array);
1692 eventDescriptorCollection = new EventDescriptorCollection(array, readOnly: true);
1693 }
1694 }
1695 return eventDescriptorCollection;
1696 }
1697
1698 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1699 public static EventDescriptorCollection GetEvents(object component)
1700 {
1701 return GetEvents(component, null, noCustomTypeDesc: false);
1702 }
1703
1704 [EditorBrowsable(EditorBrowsableState.Advanced)]
1705 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1706 public static EventDescriptorCollection GetEvents(object component, bool noCustomTypeDesc)
1707 {
1708 return GetEvents(component, null, noCustomTypeDesc);
1709 }
1710
1711 [RequiresUnreferencedCode("The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
1712 public static EventDescriptorCollection GetEvents(object component, Attribute[] attributes)
1713 {
1714 return GetEvents(component, attributes, noCustomTypeDesc: false);
1715 }
1716
1717 [EditorBrowsable(EditorBrowsableState.Advanced)]
1718 [RequiresUnreferencedCode("The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
1719 public static EventDescriptorCollection GetEvents(object component, Attribute[]? attributes, bool noCustomTypeDesc)
1720 {
1721 if (component == null)
1722 {
1723 return new EventDescriptorCollection(null, readOnly: true);
1724 }
1725 ICustomTypeDescriptor descriptor = GetDescriptor(component, noCustomTypeDesc);
1727 if (component is ICustomTypeDescriptor)
1728 {
1729 collection = descriptor.GetEvents(attributes);
1730 if (noCustomTypeDesc)
1731 {
1732 ICustomTypeDescriptor extendedDescriptor = GetExtendedDescriptor(component);
1733 if (extendedDescriptor != null)
1734 {
1735 ICollection events = extendedDescriptor.GetEvents(attributes);
1736 collection = PipelineMerge(2, collection, events, component, null);
1737 }
1738 }
1739 else
1740 {
1741 collection = PipelineFilter(2, collection, component, null);
1742 collection = PipelineAttributeFilter(2, collection, attributes, component, null);
1743 }
1744 }
1745 else
1746 {
1747 IDictionary cache = GetCache(component);
1748 collection = descriptor.GetEvents(attributes);
1750 ICustomTypeDescriptor extendedDescriptor2 = GetExtendedDescriptor(component);
1751 if (extendedDescriptor2 != null)
1752 {
1753 ICollection events2 = extendedDescriptor2.GetEvents(attributes);
1754 collection = PipelineMerge(2, collection, events2, component, cache);
1755 }
1756 collection = PipelineFilter(2, collection, component, cache);
1757 collection = PipelineAttributeFilter(2, collection, attributes, component, cache);
1758 }
1759 EventDescriptorCollection eventDescriptorCollection = collection as EventDescriptorCollection;
1760 if (eventDescriptorCollection == null)
1761 {
1763 collection.CopyTo(array, 0);
1764 eventDescriptorCollection = new EventDescriptorCollection(array, readOnly: true);
1765 }
1766 return eventDescriptorCollection;
1767 }
1768
1769 private static string GetExtenderCollisionSuffix(MemberDescriptor member)
1770 {
1771 string result = null;
1772 IExtenderProvider extenderProvider = ((member.Attributes[typeof(ExtenderProvidedPropertyAttribute)] is ExtenderProvidedPropertyAttribute extenderProvidedPropertyAttribute) ? extenderProvidedPropertyAttribute.Provider : null);
1773 if (extenderProvider != null)
1774 {
1775 string text = null;
1776 if (extenderProvider is IComponent { Site: not null } component)
1777 {
1778 text = component.Site.Name;
1779 }
1780 if (text == null || text.Length == 0)
1781 {
1783 }
1784 result = "_" + text;
1785 }
1786 return result;
1787 }
1788
1789 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
1790 public static string? GetFullComponentName(object component)
1791 {
1792 if (component == null)
1793 {
1794 throw new ArgumentNullException("component");
1795 }
1796 return GetProvider(component).GetFullComponentName(component);
1797 }
1798
1799 private static Type GetNodeForBaseType(Type searchType)
1800 {
1801 if (searchType.IsInterface)
1802 {
1803 return InterfaceType;
1804 }
1805 if (searchType == InterfaceType)
1806 {
1807 return null;
1808 }
1809 return searchType.BaseType;
1810 }
1811
1812 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
1813 public static PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
1814 {
1815 if (componentType == null)
1816 {
1817 return new PropertyDescriptorCollection(null, readOnly: true);
1818 }
1819 return GetDescriptor(componentType, "componentType").GetProperties();
1820 }
1821
1822 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
1823 public static PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, Attribute[]? attributes)
1824 {
1825 if (componentType == null)
1826 {
1827 return new PropertyDescriptorCollection(null, readOnly: true);
1828 }
1829 PropertyDescriptorCollection propertyDescriptorCollection = GetDescriptor(componentType, "componentType").GetProperties(attributes);
1830 if (attributes != null && attributes.Length != 0)
1831 {
1832 ArrayList arrayList = FilterMembers(propertyDescriptorCollection, attributes);
1833 if (arrayList != null)
1834 {
1836 arrayList.CopyTo(array);
1837 propertyDescriptorCollection = new PropertyDescriptorCollection(array, readOnly: true);
1838 }
1839 }
1840 return propertyDescriptorCollection;
1841 }
1842
1843 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered.")]
1844 public static PropertyDescriptorCollection GetProperties(object component)
1845 {
1846 return GetProperties(component, noCustomTypeDesc: false);
1847 }
1848
1849 [EditorBrowsable(EditorBrowsableState.Advanced)]
1850 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered.")]
1851 public static PropertyDescriptorCollection GetProperties(object component, bool noCustomTypeDesc)
1852 {
1853 return GetPropertiesImpl(component, null, noCustomTypeDesc, noAttributes: true);
1854 }
1855
1856 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
1857 public static PropertyDescriptorCollection GetProperties(object component, Attribute[]? attributes)
1858 {
1859 return GetProperties(component, attributes, noCustomTypeDesc: false);
1860 }
1861
1862 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
1863 public static PropertyDescriptorCollection GetProperties(object component, Attribute[]? attributes, bool noCustomTypeDesc)
1864 {
1865 return GetPropertiesImpl(component, attributes, noCustomTypeDesc, noAttributes: false);
1866 }
1867
1868 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
1869 private static PropertyDescriptorCollection GetPropertiesImpl(object component, Attribute[] attributes, bool noCustomTypeDesc, bool noAttributes)
1870 {
1871 if (component == null)
1872 {
1873 return new PropertyDescriptorCollection(null, readOnly: true);
1874 }
1875 ICustomTypeDescriptor descriptor = GetDescriptor(component, noCustomTypeDesc);
1877 if (component is ICustomTypeDescriptor)
1878 {
1879 collection = (noAttributes ? descriptor.GetProperties() : descriptor.GetProperties(attributes));
1880 if (noCustomTypeDesc)
1881 {
1882 ICustomTypeDescriptor extendedDescriptor = GetExtendedDescriptor(component);
1883 if (extendedDescriptor != null)
1884 {
1885 ICollection secondary = (noAttributes ? extendedDescriptor.GetProperties() : extendedDescriptor.GetProperties(attributes));
1886 collection = PipelineMerge(1, collection, secondary, component, null);
1887 }
1888 }
1889 else
1890 {
1891 collection = PipelineFilter(1, collection, component, null);
1892 collection = PipelineAttributeFilter(1, collection, attributes, component, null);
1893 }
1894 }
1895 else
1896 {
1897 IDictionary cache = GetCache(component);
1898 collection = (noAttributes ? descriptor.GetProperties() : descriptor.GetProperties(attributes));
1900 ICustomTypeDescriptor extendedDescriptor2 = GetExtendedDescriptor(component);
1901 if (extendedDescriptor2 != null)
1902 {
1903 ICollection secondary2 = (noAttributes ? extendedDescriptor2.GetProperties() : extendedDescriptor2.GetProperties(attributes));
1904 collection = PipelineMerge(1, collection, secondary2, component, cache);
1905 }
1906 collection = PipelineFilter(1, collection, component, cache);
1907 collection = PipelineAttributeFilter(1, collection, attributes, component, cache);
1908 }
1910 if (propertyDescriptorCollection == null)
1911 {
1913 collection.CopyTo(array, 0);
1914 propertyDescriptorCollection = new PropertyDescriptorCollection(array, readOnly: true);
1915 }
1916 return propertyDescriptorCollection;
1917 }
1918
1919 [EditorBrowsable(EditorBrowsableState.Advanced)]
1921 {
1922 if (type == null)
1923 {
1924 throw new ArgumentNullException("type");
1925 }
1926 return NodeFor(type, createDelegator: true);
1927 }
1928
1929 [EditorBrowsable(EditorBrowsableState.Advanced)]
1930 public static TypeDescriptionProvider GetProvider(object instance)
1931 {
1932 if (instance == null)
1933 {
1934 throw new ArgumentNullException("instance");
1935 }
1936 return NodeFor(instance, createDelegator: true);
1937 }
1938
1940 {
1941 return NodeFor(type, createDelegator: false);
1942 }
1943
1944 [EditorBrowsable(EditorBrowsableState.Advanced)]
1945 [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields)]
1946 public static Type GetReflectionType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicFields)] Type type)
1947 {
1948 if (type == null)
1949 {
1950 throw new ArgumentNullException("type");
1951 }
1952 return NodeFor(type).GetReflectionType(type);
1953 }
1954
1955 [EditorBrowsable(EditorBrowsableState.Advanced)]
1956 [RequiresUnreferencedCode("GetReflectionType is not trim compatible because the Type of object cannot be statically discovered.")]
1957 public static Type GetReflectionType(object instance)
1958 {
1959 if (instance == null)
1960 {
1961 throw new ArgumentNullException("instance");
1962 }
1963 return NodeFor(instance).GetReflectionType(instance);
1964 }
1965
1967 {
1968 return NodeFor(type, createDelegator: false);
1969 }
1970
1971 private static TypeDescriptionNode NodeFor(Type type, bool createDelegator)
1972 {
1974 TypeDescriptionNode typeDescriptionNode = null;
1975 Type type2 = type;
1976 while (typeDescriptionNode == null)
1977 {
1978 typeDescriptionNode = ((TypeDescriptionNode)s_providerTypeTable[type2]) ?? ((TypeDescriptionNode)s_providerTable[type2]);
1979 if (typeDescriptionNode != null)
1980 {
1981 continue;
1982 }
1983 Type nodeForBaseType = GetNodeForBaseType(type2);
1984 if (type2 == typeof(object) || nodeForBaseType == null)
1985 {
1986 lock (s_providerTable)
1987 {
1988 typeDescriptionNode = (TypeDescriptionNode)s_providerTable[type2];
1989 if (typeDescriptionNode == null)
1990 {
1991 typeDescriptionNode = new TypeDescriptionNode(new ReflectTypeDescriptionProvider());
1992 s_providerTable[type2] = typeDescriptionNode;
1993 }
1994 }
1995 }
1996 else if (createDelegator)
1997 {
1998 typeDescriptionNode = new TypeDescriptionNode(new DelegatingTypeDescriptionProvider(nodeForBaseType));
1999 lock (s_providerTable)
2000 {
2001 s_providerTypeTable[type2] = typeDescriptionNode;
2002 }
2003 }
2004 else
2005 {
2006 type2 = nodeForBaseType;
2007 }
2008 }
2009 return typeDescriptionNode;
2010 }
2011
2012 private static TypeDescriptionNode NodeFor(object instance)
2013 {
2014 return NodeFor(instance, createDelegator: false);
2015 }
2016
2017 private static TypeDescriptionNode NodeFor(object instance, bool createDelegator)
2018 {
2019 TypeDescriptionNode typeDescriptionNode = (TypeDescriptionNode)s_providerTable[instance];
2020 if (typeDescriptionNode == null)
2021 {
2022 Type type = instance.GetType();
2023 if (type.IsCOMObject)
2024 {
2026 }
2027 typeDescriptionNode = ((!createDelegator) ? NodeFor(type) : new TypeDescriptionNode(new DelegatingTypeDescriptionProvider(type)));
2028 }
2029 return typeDescriptionNode;
2030 }
2031
2032 private static void NodeRemove(object key, TypeDescriptionProvider provider)
2033 {
2034 lock (s_providerTable)
2035 {
2037 TypeDescriptionNode typeDescriptionNode2 = typeDescriptionNode;
2038 TypeDescriptionNode typeDescriptionNode3 = null;
2039 while (typeDescriptionNode2 != null && typeDescriptionNode2.Provider != provider)
2040 {
2041 typeDescriptionNode3 = typeDescriptionNode2;
2042 typeDescriptionNode2 = typeDescriptionNode2.Next;
2043 }
2044 if (typeDescriptionNode2 == null)
2045 {
2046 return;
2047 }
2048 if (typeDescriptionNode2.Next != null)
2049 {
2050 typeDescriptionNode2.Provider = typeDescriptionNode2.Next.Provider;
2051 typeDescriptionNode2.Next = typeDescriptionNode2.Next.Next;
2052 if (typeDescriptionNode2 == typeDescriptionNode && typeDescriptionNode2.Provider is DelegatingTypeDescriptionProvider)
2053 {
2054 s_providerTable.Remove(key);
2055 }
2056 }
2057 else if (typeDescriptionNode2 != typeDescriptionNode)
2058 {
2059 Type type = (key as Type) ?? key.GetType();
2060 typeDescriptionNode2.Provider = new DelegatingTypeDescriptionProvider(type.BaseType);
2061 }
2062 else
2063 {
2064 s_providerTable.Remove(key);
2065 }
2066 s_providerTypeTable.Clear();
2067 }
2068 }
2069
2070 [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
2071 private static ICollection PipelineAttributeFilter(int pipelineType, ICollection members, Attribute[] filter, object instance, IDictionary cache)
2072 {
2073 IList list = members as ArrayList;
2074 if (filter == null || filter.Length == 0)
2075 {
2076 return members;
2077 }
2078 if (cache != null && (list == null || list.IsReadOnly) && cache[s_pipelineAttributeFilterKeys[pipelineType]] is AttributeFilterCacheItem attributeFilterCacheItem && attributeFilterCacheItem.IsValid(filter))
2079 {
2080 return attributeFilterCacheItem.FilteredMembers;
2081 }
2082 if (list == null || list.IsReadOnly)
2083 {
2084 list = new ArrayList(members);
2085 }
2086 ArrayList arrayList = FilterMembers(list, filter);
2087 if (arrayList != null)
2088 {
2089 list = arrayList;
2090 }
2091 if (cache != null)
2092 {
2093 ICollection filteredMembers;
2094 switch (pipelineType)
2095 {
2096 case 1:
2097 {
2098 PropertyDescriptor[] array2 = new PropertyDescriptor[list.Count];
2099 list.CopyTo(array2, 0);
2100 filteredMembers = new PropertyDescriptorCollection(array2, readOnly: true);
2101 break;
2102 }
2103 case 2:
2104 {
2106 list.CopyTo(array, 0);
2107 filteredMembers = new EventDescriptorCollection(array, readOnly: true);
2108 break;
2109 }
2110 default:
2111 filteredMembers = null;
2112 break;
2113 }
2114 AttributeFilterCacheItem value = new AttributeFilterCacheItem(filter, filteredMembers);
2115 cache[s_pipelineAttributeFilterKeys[pipelineType]] = value;
2116 }
2117 return list;
2118 }
2119
2120 private static ICollection PipelineFilter(int pipelineType, ICollection members, object instance, IDictionary cache)
2121 {
2122 IComponent component = instance as IComponent;
2123 ITypeDescriptorFilterService typeDescriptorFilterService = null;
2124 ISite site = component?.Site;
2125 if (site != null)
2126 {
2127 typeDescriptorFilterService = site.GetService(typeof(ITypeDescriptorFilterService)) as ITypeDescriptorFilterService;
2128 }
2129 IList list = members as ArrayList;
2130 if (typeDescriptorFilterService == null)
2131 {
2132 return members;
2133 }
2134 if (cache != null && (list == null || list.IsReadOnly) && cache[s_pipelineFilterKeys[pipelineType]] is FilterCacheItem filterCacheItem && filterCacheItem.IsValid(typeDescriptorFilterService))
2135 {
2136 return filterCacheItem.FilteredMembers;
2137 }
2138 OrderedDictionary orderedDictionary = new OrderedDictionary(members.Count);
2139 bool flag;
2140 switch (pipelineType)
2141 {
2142 case 0:
2143 foreach (Attribute member in members)
2144 {
2145 orderedDictionary[member.TypeId] = member;
2146 }
2147 flag = typeDescriptorFilterService.FilterAttributes(component, orderedDictionary);
2148 break;
2149 case 1:
2150 case 2:
2151 foreach (MemberDescriptor member2 in members)
2152 {
2153 string name = member2.Name;
2154 if (orderedDictionary.Contains(name))
2155 {
2156 string extenderCollisionSuffix = GetExtenderCollisionSuffix(member2);
2157 if (extenderCollisionSuffix != null)
2158 {
2159 orderedDictionary[name + extenderCollisionSuffix] = member2;
2160 }
2161 MemberDescriptor memberDescriptor2 = (MemberDescriptor)orderedDictionary[name];
2162 extenderCollisionSuffix = GetExtenderCollisionSuffix(memberDescriptor2);
2163 if (extenderCollisionSuffix != null)
2164 {
2165 orderedDictionary.Remove(name);
2166 orderedDictionary[memberDescriptor2.Name + extenderCollisionSuffix] = memberDescriptor2;
2167 }
2168 }
2169 else
2170 {
2171 orderedDictionary[name] = member2;
2172 }
2173 }
2174 flag = ((pipelineType != 1) ? typeDescriptorFilterService.FilterEvents(component, orderedDictionary) : typeDescriptorFilterService.FilterProperties(component, orderedDictionary));
2175 break;
2176 default:
2177 flag = false;
2178 break;
2179 }
2180 if (list == null || list.IsReadOnly)
2181 {
2182 list = new ArrayList(orderedDictionary.Values);
2183 }
2184 else
2185 {
2186 list.Clear();
2187 foreach (object value2 in orderedDictionary.Values)
2188 {
2189 list.Add(value2);
2190 }
2191 }
2192 if (flag && cache != null)
2193 {
2194 ICollection filteredMembers;
2195 switch (pipelineType)
2196 {
2197 case 0:
2198 {
2199 Attribute[] array2 = new Attribute[list.Count];
2200 try
2201 {
2202 list.CopyTo(array2, 0);
2203 }
2204 catch (InvalidCastException)
2205 {
2207 }
2208 filteredMembers = new AttributeCollection(array2);
2209 break;
2210 }
2211 case 1:
2212 {
2213 PropertyDescriptor[] array3 = new PropertyDescriptor[list.Count];
2214 try
2215 {
2216 list.CopyTo(array3, 0);
2217 }
2218 catch (InvalidCastException)
2219 {
2221 }
2222 filteredMembers = new PropertyDescriptorCollection(array3, readOnly: true);
2223 break;
2224 }
2225 case 2:
2226 {
2228 try
2229 {
2230 list.CopyTo(array, 0);
2231 }
2232 catch (InvalidCastException)
2233 {
2235 }
2236 filteredMembers = new EventDescriptorCollection(array, readOnly: true);
2237 break;
2238 }
2239 default:
2240 filteredMembers = null;
2241 break;
2242 }
2243 FilterCacheItem value = new FilterCacheItem(typeDescriptorFilterService, filteredMembers);
2244 cache[s_pipelineFilterKeys[pipelineType]] = value;
2245 cache.Remove(s_pipelineAttributeFilterKeys[pipelineType]);
2246 }
2247 return list;
2248 }
2249
2250 private static ICollection PipelineInitialize(int pipelineType, ICollection members, IDictionary cache)
2251 {
2252 if (cache != null)
2253 {
2254 bool flag = true;
2255 if (cache[s_pipelineInitializeKeys[pipelineType]] is ICollection collection && collection.Count == members.Count)
2256 {
2257 IEnumerator enumerator = collection.GetEnumerator();
2258 IEnumerator enumerator2 = members.GetEnumerator();
2259 while (enumerator.MoveNext() && enumerator2.MoveNext())
2260 {
2261 if (enumerator.Current != enumerator2.Current)
2262 {
2263 flag = false;
2264 break;
2265 }
2266 }
2267 }
2268 if (!flag)
2269 {
2270 cache.Remove(s_pipelineMergeKeys[pipelineType]);
2271 cache.Remove(s_pipelineFilterKeys[pipelineType]);
2272 cache.Remove(s_pipelineAttributeFilterKeys[pipelineType]);
2273 cache[s_pipelineInitializeKeys[pipelineType]] = members;
2274 }
2275 }
2276 return members;
2277 }
2278
2279 private static ICollection PipelineMerge(int pipelineType, ICollection primary, ICollection secondary, object instance, IDictionary cache)
2280 {
2281 if (secondary == null || secondary.Count == 0)
2282 {
2283 return primary;
2284 }
2285 if (cache?[s_pipelineMergeKeys[pipelineType]] is ICollection collection && collection.Count == primary.Count + secondary.Count)
2286 {
2287 IEnumerator enumerator = collection.GetEnumerator();
2288 IEnumerator enumerator2 = primary.GetEnumerator();
2289 bool flag = true;
2290 while (enumerator2.MoveNext() && enumerator.MoveNext())
2291 {
2292 if (enumerator2.Current != enumerator.Current)
2293 {
2294 flag = false;
2295 break;
2296 }
2297 }
2298 if (flag)
2299 {
2300 IEnumerator enumerator3 = secondary.GetEnumerator();
2301 while (enumerator3.MoveNext() && enumerator.MoveNext())
2302 {
2303 if (enumerator3.Current != enumerator.Current)
2304 {
2305 flag = false;
2306 break;
2307 }
2308 }
2309 }
2310 if (flag)
2311 {
2312 return collection;
2313 }
2314 }
2315 ArrayList arrayList = new ArrayList(primary.Count + secondary.Count);
2316 foreach (object item in primary)
2317 {
2318 arrayList.Add(item);
2319 }
2320 foreach (object item2 in secondary)
2321 {
2322 arrayList.Add(item2);
2323 }
2324 if (cache != null)
2325 {
2327 switch (pipelineType)
2328 {
2329 case 0:
2330 {
2331 Attribute[] array3 = new Attribute[arrayList.Count];
2332 arrayList.CopyTo(array3, 0);
2333 value = new AttributeCollection(array3);
2334 break;
2335 }
2336 case 1:
2337 {
2338 PropertyDescriptor[] array2 = new PropertyDescriptor[arrayList.Count];
2339 arrayList.CopyTo(array2, 0);
2340 value = new PropertyDescriptorCollection(array2, readOnly: true);
2341 break;
2342 }
2343 case 2:
2344 {
2345 EventDescriptor[] array = new EventDescriptor[arrayList.Count];
2346 arrayList.CopyTo(array, 0);
2347 value = new EventDescriptorCollection(array, readOnly: true);
2348 break;
2349 }
2350 default:
2351 value = null;
2352 break;
2353 }
2354 cache[s_pipelineMergeKeys[pipelineType]] = value;
2355 cache.Remove(s_pipelineFilterKeys[pipelineType]);
2356 cache.Remove(s_pipelineAttributeFilterKeys[pipelineType]);
2357 }
2358 return arrayList;
2359 }
2360
2361 private static void RaiseRefresh(object component)
2362 {
2363 Volatile.Read(ref TypeDescriptor.Refreshed)?.Invoke(new RefreshEventArgs(component));
2364 }
2365
2366 private static void RaiseRefresh(Type type)
2367 {
2369 }
2370
2371 public static void Refresh(object component)
2372 {
2373 Refresh(component, refreshReflectionProvider: true);
2374 }
2375
2376 private static void Refresh(object component, bool refreshReflectionProvider)
2377 {
2378 if (component == null)
2379 {
2380 return;
2381 }
2382 bool flag = false;
2383 if (refreshReflectionProvider)
2384 {
2385 Type type = component.GetType();
2386 lock (s_providerTable)
2387 {
2388 IDictionaryEnumerator enumerator = s_providerTable.GetEnumerator();
2389 while (enumerator.MoveNext())
2390 {
2391 DictionaryEntry entry = enumerator.Entry;
2392 Type type2 = entry.Key as Type;
2393 if ((!(type2 != null) || !type.IsAssignableFrom(type2)) && !(type2 == typeof(object)))
2394 {
2395 continue;
2396 }
2397 TypeDescriptionNode typeDescriptionNode = (TypeDescriptionNode)entry.Value;
2398 while (typeDescriptionNode != null && !(typeDescriptionNode.Provider is ReflectTypeDescriptionProvider))
2399 {
2400 flag = true;
2401 typeDescriptionNode = typeDescriptionNode.Next;
2402 }
2403 if (typeDescriptionNode != null)
2404 {
2405 ReflectTypeDescriptionProvider reflectTypeDescriptionProvider = (ReflectTypeDescriptionProvider)typeDescriptionNode.Provider;
2406 if (reflectTypeDescriptionProvider.IsPopulated(type))
2407 {
2408 flag = true;
2409 reflectTypeDescriptionProvider.Refresh(type);
2410 }
2411 }
2412 }
2413 }
2414 }
2415 IDictionary cache = GetCache(component);
2416 if (!flag && cache == null)
2417 {
2418 return;
2419 }
2420 if (cache != null)
2421 {
2422 for (int i = 0; i < s_pipelineFilterKeys.Length; i++)
2423 {
2424 cache.Remove(s_pipelineFilterKeys[i]);
2425 cache.Remove(s_pipelineMergeKeys[i]);
2427 }
2428 }
2430 RaiseRefresh(component);
2431 }
2432
2433 public static void Refresh(Type type)
2434 {
2435 if (type == null)
2436 {
2437 return;
2438 }
2439 bool flag = false;
2440 lock (s_providerTable)
2441 {
2442 IDictionaryEnumerator enumerator = s_providerTable.GetEnumerator();
2443 while (enumerator.MoveNext())
2444 {
2445 DictionaryEntry entry = enumerator.Entry;
2446 Type type2 = entry.Key as Type;
2447 if ((!(type2 != null) || !type.IsAssignableFrom(type2)) && !(type2 == typeof(object)))
2448 {
2449 continue;
2450 }
2451 TypeDescriptionNode typeDescriptionNode = (TypeDescriptionNode)entry.Value;
2452 while (typeDescriptionNode != null && !(typeDescriptionNode.Provider is ReflectTypeDescriptionProvider))
2453 {
2454 flag = true;
2455 typeDescriptionNode = typeDescriptionNode.Next;
2456 }
2457 if (typeDescriptionNode != null)
2458 {
2459 ReflectTypeDescriptionProvider reflectTypeDescriptionProvider = (ReflectTypeDescriptionProvider)typeDescriptionNode.Provider;
2460 if (reflectTypeDescriptionProvider.IsPopulated(type))
2461 {
2462 flag = true;
2463 reflectTypeDescriptionProvider.Refresh(type);
2464 }
2465 }
2466 }
2467 }
2468 if (flag)
2469 {
2472 }
2473 }
2474
2475 public static void Refresh(Module module)
2476 {
2477 if (module == null)
2478 {
2479 return;
2480 }
2481 Hashtable hashtable = null;
2482 lock (s_providerTable)
2483 {
2484 IDictionaryEnumerator enumerator = s_providerTable.GetEnumerator();
2485 while (enumerator.MoveNext())
2486 {
2487 DictionaryEntry entry = enumerator.Entry;
2488 Type type = entry.Key as Type;
2489 if ((!(type != null) || !type.Module.Equals(module)) && !(type == typeof(object)))
2490 {
2491 continue;
2492 }
2493 TypeDescriptionNode typeDescriptionNode = (TypeDescriptionNode)entry.Value;
2494 while (typeDescriptionNode != null && !(typeDescriptionNode.Provider is ReflectTypeDescriptionProvider))
2495 {
2496 if (hashtable == null)
2497 {
2498 hashtable = new Hashtable();
2499 }
2500 hashtable[type] = type;
2501 typeDescriptionNode = typeDescriptionNode.Next;
2502 }
2503 if (typeDescriptionNode == null)
2504 {
2505 continue;
2506 }
2507 ReflectTypeDescriptionProvider reflectTypeDescriptionProvider = (ReflectTypeDescriptionProvider)typeDescriptionNode.Provider;
2508 Type[] populatedTypes = reflectTypeDescriptionProvider.GetPopulatedTypes(module);
2509 Type[] array = populatedTypes;
2510 foreach (Type type2 in array)
2511 {
2512 reflectTypeDescriptionProvider.Refresh(type2);
2513 if (hashtable == null)
2514 {
2515 hashtable = new Hashtable();
2516 }
2517 hashtable[type2] = type2;
2518 }
2519 }
2520 }
2521 if (hashtable == null || TypeDescriptor.Refreshed == null)
2522 {
2523 return;
2524 }
2525 foreach (Type key in hashtable.Keys)
2526 {
2528 }
2529 }
2530
2531 public static void Refresh(Assembly assembly)
2532 {
2533 if (!(assembly == null))
2534 {
2535 Module[] modules = assembly.GetModules();
2536 foreach (Module module in modules)
2537 {
2538 Refresh(module);
2539 }
2540 }
2541 }
2542
2543 [RequiresUnreferencedCode("The Type of component cannot be statically discovered.")]
2544 public static IDesigner? CreateDesigner(IComponent component, Type designerBaseType)
2545 {
2546 Type type = null;
2547 IDesigner result = null;
2548 AttributeCollection attributes = GetAttributes(component);
2549 for (int i = 0; i < attributes.Count; i++)
2550 {
2551 if (!(attributes[i] is DesignerAttribute designerAttribute))
2552 {
2553 continue;
2554 }
2555 Type type2 = Type.GetType(designerAttribute.DesignerBaseTypeName);
2556 if (type2 != null && type2 == designerBaseType)
2557 {
2558 ISite site = component.Site;
2559 bool flag = false;
2560 ITypeResolutionService typeResolutionService = (ITypeResolutionService)(site?.GetService(typeof(ITypeResolutionService)));
2561 if (typeResolutionService != null)
2562 {
2563 flag = true;
2564 type = typeResolutionService.GetType(designerAttribute.DesignerTypeName);
2565 }
2566 if (!flag)
2567 {
2568 type = Type.GetType(designerAttribute.DesignerTypeName);
2569 }
2570 if (type != null)
2571 {
2572 break;
2573 }
2574 }
2575 }
2576 if (type != null)
2577 {
2579 }
2580 return result;
2581 }
2582
2583 [EditorBrowsable(EditorBrowsableState.Advanced)]
2584 public static void RemoveAssociation(object primary, object secondary)
2585 {
2586 if (primary == null)
2587 {
2588 throw new ArgumentNullException("primary");
2589 }
2590 if (secondary == null)
2591 {
2592 throw new ArgumentNullException("secondary");
2593 }
2594 IList list = (IList)(AssociationTable?[primary]);
2595 if (list == null)
2596 {
2597 return;
2598 }
2599 lock (list)
2600 {
2601 for (int num = list.Count - 1; num >= 0; num--)
2602 {
2603 WeakReference weakReference = (WeakReference)list[num];
2604 object target = weakReference.Target;
2605 if (target == null || target == secondary)
2606 {
2607 list.RemoveAt(num);
2608 }
2609 }
2610 }
2611 }
2612
2613 [EditorBrowsable(EditorBrowsableState.Advanced)]
2614 public static void RemoveAssociations(object primary)
2615 {
2616 if (primary == null)
2617 {
2618 throw new ArgumentNullException("primary");
2619 }
2620 AssociationTable?.Remove(primary);
2621 }
2622
2623 [EditorBrowsable(EditorBrowsableState.Advanced)]
2624 public static void RemoveProvider(TypeDescriptionProvider provider, Type type)
2625 {
2626 if (provider == null)
2627 {
2628 throw new ArgumentNullException("provider");
2629 }
2630 if (type == null)
2631 {
2632 throw new ArgumentNullException("type");
2633 }
2634 NodeRemove(type, provider);
2636 }
2637
2638 [EditorBrowsable(EditorBrowsableState.Advanced)]
2639 public static void RemoveProvider(TypeDescriptionProvider provider, object instance)
2640 {
2641 if (provider == null)
2642 {
2643 throw new ArgumentNullException("provider");
2644 }
2645 if (instance == null)
2646 {
2647 throw new ArgumentNullException("instance");
2648 }
2649 NodeRemove(instance, provider);
2650 RaiseRefresh(instance);
2651 }
2652
2653 [EditorBrowsable(EditorBrowsableState.Advanced)]
2655 {
2656 if (provider == null)
2657 {
2658 throw new ArgumentNullException("provider");
2659 }
2660 if (type == null)
2661 {
2662 throw new ArgumentNullException("type");
2663 }
2664 RemoveProvider(provider, type);
2665 }
2666
2667 [EditorBrowsable(EditorBrowsableState.Advanced)]
2668 public static void RemoveProviderTransparent(TypeDescriptionProvider provider, object instance)
2669 {
2670 if (provider == null)
2671 {
2672 throw new ArgumentNullException("provider");
2673 }
2674 if (instance == null)
2675 {
2676 throw new ArgumentNullException("instance");
2677 }
2678 RemoveProvider(provider, instance);
2679 }
2680
2681 [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
2682 private static bool ShouldHideMember(MemberDescriptor member, Attribute attribute)
2683 {
2684 if (member == null || attribute == null)
2685 {
2686 return true;
2687 }
2688 Attribute attribute2 = member.Attributes[attribute.GetType()];
2689 if (attribute2 == null)
2690 {
2691 return !attribute.IsDefaultAttribute();
2692 }
2693 return !attribute.Match(attribute2);
2694 }
2695
2696 public static void SortDescriptorArray(IList infos)
2697 {
2698 if (infos == null)
2699 {
2700 throw new ArgumentNullException("infos");
2701 }
2703 }
2704}
static ? object CreateInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture)
Definition Activator.cs:17
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
virtual object TypeId
Definition Attribute.cs:13
override bool Equals([NotNullWhen(true)] object? obj)
Definition Attribute.cs:691
virtual bool Match(object? obj)
Definition Attribute.cs:786
virtual bool IsDefaultAttribute()
Definition Attribute.cs:791
virtual int Add(object? value)
static ArrayList Adapter(IList list)
virtual void CopyTo(Array array)
virtual AttributeCollection Attributes
static void AddEditorTable(Type editorBaseType, Hashtable table)
virtual ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
ICustomTypeDescriptor? GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType)
AttributeFilterCacheItem(Attribute[] filter, ICollection filteredMembers)
AttributeTypeDescriptor(Attribute[] attrs, ICustomTypeDescriptor parent)
AttributeProvider(TypeDescriptionProvider existingProvider, params Attribute[] attrs)
override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
ComNativeDescriptionProvider(IComNativeDescriptorHandler handler)
override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
readonly ITypeDescriptorFilterService _filterService
bool IsValid(ITypeDescriptorFilterService filterService)
FilterCacheItem(ITypeDescriptorFilterService filterService, ICollection filteredMembers)
MergedTypeDescriptor(ICustomTypeDescriptor primary, ICustomTypeDescriptor secondary)
override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance)
override Type GetReflectionType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor|DynamicallyAccessedMemberTypes.PublicFields)] Type objectType, object instance)
override object CreateInstance(IServiceProvider provider, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType, Type[] argTypes, object[] args)
override ICustomTypeDescriptor GetTypeDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
override IExtenderProvider[] GetExtenderProviders(object instance)
static Type GetReflectionType(object instance)
static ICollection PipelineMerge(int pipelineType, ICollection primary, ICollection secondary, object instance, IDictionary cache)
static readonly object s_internalSyncObject
static void AddProvider(TypeDescriptionProvider provider, Type type)
static void AddProviderTransparent(TypeDescriptionProvider provider, object instance)
static void RemoveProvider(TypeDescriptionProvider provider, object instance)
static readonly Hashtable s_providerTypeTable
static readonly Guid[] s_pipelineMergeKeys
static readonly Guid[] s_pipelineFilterKeys
static PropertyDescriptor CreateProperty([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, PropertyDescriptor oldPropertyDescriptor, params Attribute[] attributes)
static ArrayList FilterMembers(IList members, Attribute[] attributes)
static readonly WeakHashtable s_providerTable
static PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static void RemoveAssociation(object primary, object secondary)
static PropertyDescriptorCollection GetPropertiesImpl(object component, Attribute[] attributes, bool noCustomTypeDesc, bool noAttributes)
static ? IDesigner CreateDesigner(IComponent component, Type designerBaseType)
static TypeDescriptionProvider GetProviderRecursive(Type type)
static AttributeCollection GetAttributes(object component)
static string GetExtenderCollisionSuffix(MemberDescriptor member)
static readonly Hashtable s_defaultProviders
static Type GetReflectionType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor|DynamicallyAccessedMemberTypes.PublicFields)] Type type)
static PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, Attribute[]? attributes)
static void CreateAssociation(object primary, object secondary)
static void AddProviderTransparent(TypeDescriptionProvider provider, Type type)
static TypeDescriptionNode NodeFor(object instance)
static ICollection PipelineAttributeFilter(int pipelineType, ICollection members, Attribute[] filter, object instance, IDictionary cache)
static void Refresh(object component, bool refreshReflectionProvider)
static EventDescriptorCollection GetEvents([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static ? object GetEditor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, Type editorBaseType)
static EventDescriptorCollection GetEvents(object component, Attribute[] attributes)
static TypeDescriptionNode NodeFor(object instance, bool createDelegator)
static EventDescriptor CreateEvent([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, string name, Type type, params Attribute[] attributes)
static TypeDescriptionNode NodeFor(Type type)
static EventDescriptorCollection GetEvents(object component, bool noCustomTypeDesc)
static TypeConverter GetConverterTrimUnsafe([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
static ICollection PipelineInitialize(int pipelineType, ICollection members, IDictionary cache)
static TypeDescriptionProvider AddAttributes(object instance, params Attribute[] attributes)
static ? string GetClassName([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static PropertyDescriptorCollection GetProperties(object component)
static ? object GetEditor(object component, Type editorBaseType)
static void RemoveProvider(TypeDescriptionProvider provider, Type type)
static ? string GetClassName(object component)
static TypeConverter GetConverter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type)
static TypeConverter GetConverter(object component)
static ? string GetFullComponentName(object component)
static void AddProvider(TypeDescriptionProvider provider, object instance)
static void NodeRemove(object key, TypeDescriptionProvider provider)
static object GetAssociation(Type type, object primary)
static AttributeCollection GetAttributes(object component, bool noCustomTypeDesc)
static ? object CreateInstance(IServiceProvider? provider, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type objectType, Type[]? argTypes, object[]? args)
static PropertyDescriptorCollection GetProperties(object component, Attribute[]? attributes, bool noCustomTypeDesc)
static TypeDescriptionNode NodeFor(Type type, bool createDelegator)
static void Refresh(Module module)
static ICustomTypeDescriptor GetDescriptor([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, string typeName)
static EventDescriptorCollection GetEvents(object component, Attribute[]? attributes, bool noCustomTypeDesc)
static PropertyDescriptorCollection GetProperties(object component, Attribute[]? attributes)
static ? EventDescriptor GetDefaultEvent(object component)
static readonly Guid[] s_pipelineAttributeFilterKeys
static readonly Guid[] s_pipelineInitializeKeys
static ? EventDescriptor GetDefaultEvent(object component, bool noCustomTypeDesc)
static void RemoveProviderTransparent(TypeDescriptionProvider provider, object instance)
static ? RefreshEventHandler Refreshed
static EventDescriptor CreateEvent([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, EventDescriptor oldEventDescriptor, params Attribute[] attributes)
static void AddEditorTable(Type editorBaseType, Hashtable table)
static ICustomTypeDescriptor GetExtendedDescriptor(object component)
static void RemoveAssociations(object primary)
static void SortDescriptorArray(IList infos)
static ? EventDescriptor GetDefaultEvent([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static ? string GetComponentName(object component)
static ICustomTypeDescriptor GetDescriptor(object component, bool noCustomTypeDesc)
static TypeDescriptionProvider GetProvider(Type type)
static void RaiseRefresh(object component)
static void CheckDefaultProvider(Type type)
static object ConvertFromInvariantString([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, string stringValue)
static PropertyDescriptor CreateProperty([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, string name, Type type, params Attribute[] attributes)
static ? PropertyDescriptor GetDefaultProperty(object component)
static ICollection PipelineFilter(int pipelineType, ICollection members, object instance, IDictionary cache)
static EventDescriptorCollection GetEvents([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType, Attribute[] attributes)
static ? string GetClassName(object component, bool noCustomTypeDesc)
static ? IComNativeDescriptorHandler ComNativeDescriptorHandler
static ? PropertyDescriptor GetDefaultProperty([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static PropertyDescriptorCollection GetProperties(object component, bool noCustomTypeDesc)
static TypeDescriptionProvider GetProvider(object instance)
static AttributeCollection GetAttributes([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static void Refresh(Assembly assembly)
static void RemoveProviderTransparent(TypeDescriptionProvider provider, Type type)
static EventDescriptorCollection GetEvents(object component)
static IDictionary GetCache(object instance)
static bool ShouldHideMember(MemberDescriptor member, Attribute attribute)
static void Refresh(object component)
static TypeConverter GetConverter(object component, bool noCustomTypeDesc)
static ? string GetComponentName(object component, bool noCustomTypeDesc)
static TypeDescriptionProvider AddAttributes(Type type, params Attribute[] attributes)
static ? PropertyDescriptor GetDefaultProperty(object component, bool noCustomTypeDesc)
static ? object GetEditor(object component, Type editorBaseType, bool noCustomTypeDesc)
static Type GetNodeForBaseType(Type searchType)
void SetWeak(object key, object value)
static CultureInfo InvariantCulture
static string TypeDescriptorAlreadyAssociated
Definition SR.cs:46
static string ConvertToException
Definition SR.cs:22
static string TypeDescriptorExpectedElementType
Definition SR.cs:52
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string TypeDescriptorSameAssociation
Definition SR.cs:54
static string TypeDescriptorArgsCountMismatch
Definition SR.cs:48
static string TypeDescriptorProviderError
Definition SR.cs:50
Definition SR.cs:7
static int Increment(ref int location)
static bool Read(ref bool location)
Definition Volatile.cs:67
bool IsInterface
Definition Type.cs:30
virtual bool IsAssignableFrom([NotNullWhen(true)] Type? c)
Definition Type.cs:1561
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408
virtual bool IsInstanceOfType([NotNullWhen(true)] object? o)
Definition Type.cs:1020
Type? BaseType
Definition Type.cs:295
string? FullName
Definition Type.cs:47
virtual ? object Target
bool FilterAttributes(IComponent component, IDictionary attributes)
bool FilterProperties(IComponent component, IDictionary properties)
bool FilterEvents(IComponent component, IDictionary events)
Type? GetType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string name)
AttributeCollection GetAttributes(object component)
PropertyDescriptor GetDefaultProperty(object component)
TypeConverter GetConverter(object component)
EventDescriptor GetDefaultEvent(object component)
PropertyDescriptorCollection GetProperties(object component, Attribute[]? attributes)
EventDescriptorCollection GetEvents(object component)
object GetEditor(object component, Type baseEditorType)
object? GetEditor(Type editorBaseType)
object? GetPropertyOwner(PropertyDescriptor? pd)
PropertyDescriptorCollection GetProperties()
EventDescriptorCollection GetEvents()
object? GetService(Type serviceType)
delegate void RefreshEventHandler(RefreshEventArgs e)
DefaultTypeDescriptor(TypeDescriptionNode node, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, object instance)
static Guid NewGuid()
Definition Guid.cs:1283