-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
📌 In Support.GetResourcePath add a parameter to enable feedback on misconfiguration
Description:
Add a parameter to the Support.GetResourcePath method to control whether detailed feedback should be given (e.g., via thrown exceptions) when configuration issues are detected. This is useful during development and debugging scenarios.
Why:
Currently, when a DynamicPathSourceAttribute is present but misconfigured — either:
- the referenced property does not exist, or
- the property exists but is not of type string
…the method silently ignores the problem and falls back to other resolution steps.
Proposed Behavior:
Introduce a new optional parameter:
public static string GetResourcePath(
ITypeDescriptorContext context,
Type type,
ResourceUsage resourceUsage = ResourceUsage.All,
bool throwOnError = false)When throwOnError is set to true:
- If the referenced property does not exist, throw MissingMemberException.
- If the property exists but is not a string, throw InvalidOperationException.
This behavior makes misconfiguration immediately visible, especially in development or unit test scenarios.
Example Use Case:
var path = Support.GetResourcePath(context, typeof(MyEnum), ResourceUsage.Strings, throwOnError: true);Tasks:
- Add throwOnError parameter to GetResourcePath
- Update call sites where debug feedback is needed (possibly controlled by DebugOutput on attributes)
- Add unit tests for invalid property name and invalid property type
- Ensure designer scenarios still function (fallback behavior when throwOnError is false)
Reactions are currently unavailable