4.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T02:56:51.283838+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 708a410ec1ac79c2 |
Debug
Documentation: GeneratedInternalTypeHelper
1. Purpose
This module provides a WPF-specific runtime helper class used internally during XAML parsing and object initialization. It extends System.Windows.Markup.InternalTypeHelper to customize how objects are instantiated, property values are read/written, and event handlers are attached—primarily to support WPF’s XAML infrastructure (e.g., for x:Class, x:Name, or event wiring in compiled XAML). It is not intended for direct use by application code and is auto-generated by the PresentationBuildTasks MSBuild task during the build process.
2. Public Interface
The class is sealed and inherits from InternalTypeHelper. All members are protected override methods—not public API—but are included here for completeness.
-
protected override object CreateInstance(Type type, CultureInfo culture)
Instantiates the giventypeusing reflection, allowing both public and non-public constructors (viaBindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance). Returns the new instance. -
protected override object GetPropertyValue(PropertyInfo propertyInfo, object target, CultureInfo culture)
Reads the value ofpropertyInfoontargetusing default binding flags (BindingFlags.Default). Returns the property value. -
protected override void SetPropertyValue(PropertyInfo propertyInfo, object target, object value, CultureInfo culture)
WritesvaluetopropertyInfoontargetusing default binding flags. -
protected override Delegate CreateDelegate(Type delegateType, object target, string handler)
Dynamically creates a delegate ofdelegateTypebound to the instance method namedhandlerontarget. Uses reflection to invoke the non-public instance method_CreateDelegateontarget.GetType().
⚠️ Note: This relies on an internal implementation detail (_CreateDelegate) of the target object’s type. -
protected override void AddEventHandler(EventInfo eventInfo, object target, Delegate handler)
Attacheshandlerto the event represented byeventInfoontargetusingEventInfo.AddEventHandler.
3. Invariants
- The class is
sealedand inherits fromSystem.Windows.Markup.InternalTypeHelper, meaning it is tightly coupled to WPF’s XAML infrastructure. - All methods use reflection with explicit
BindingFlags; no method relies on dynamic invocation beyond what is visible in the source. - The
CreateDelegatemethod assumes thetargetobject’s type exposes a non-public instance method named_CreateDelegateaccepting(Type, string)—this is an internal contract with WPF’s runtime, not a documented public API. - The class is marked with
[EditorBrowsable(EditorBrowsableState.Never)], indicating it should never appear in IntelliSense or designer tooling.
4. Dependencies
- Depends on:
System.Windows.Markup.InternalTypeHelper(base class)System.Activator,System.Reflection(for reflection-based object creation/property/event handling)System.Globalization.CultureInfo(for culture-sensitive operations)PresentationBuildTasks(the MSBuild task that generates this file)
- Used by:
- WPF’s XAML compiler/runtime (e.g.,
BamlReader,XamlWriter, or generated BAML code) during deserialization or event wiring. - Likely referenced indirectly via
x:Classorx:Namein XAML files compiled into the same assembly. - Not referenced directly by application code.
- WPF’s XAML compiler/runtime (e.g.,
5. Gotchas
- Auto-generated file: This file is regenerated on every build; manual edits will be lost.
- Non-public contract: The
_CreateDelegatereflection call inCreateDelegateis fragile—it depends on an undocumented, internal method of the target type. If the target type changes or does not implement_CreateDelegate, this will throw aMissingMethodExceptionat runtime. - No public surface area: This class is strictly internal infrastructure. Developers should never instantiate or extend it.
- Culture handling: All methods accept a
CultureInfoparameter but pass it directly to reflection APIs—behavior may vary across cultures (e.g., case sensitivity in property/event names is not affected, but custom type converters might be). - No error handling visible: The source shows no explicit exception handling; failures (e.g., missing methods, inaccessible properties) will propagate as reflection exceptions.
- None identified from source alone for typical usage patterns—only the above technical caveats are evident.