{"record":{"id":"9118a6a4e0b4e0e2","repo":"HandyOrg/HandyControl","slug":"the-type-of-this-parameter-does-not-support-a-required","errorCode":null,"errorMessage":"The type of this parameter does not support a required interface","messagePattern":"The type of this parameter does not support a required interface","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs","lineNumber":206,"sourceCode":"    [DebuggerStepThrough]\n    [SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n    public static void BoundedDoubleInc(double lowerBoundInclusive, double value, double upperBoundInclusive, string message, string parameter)\n    {\n        if (value < lowerBoundInclusive || value > upperBoundInclusive)\n        {\n            throw new ArgumentException(message, parameter);\n        }\n    }\n\n    [DebuggerStepThrough]\n    [SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n    public static void TypeSupportsInterface(Type type, Type interfaceType, string parameterName)\n    {\n        Verify.IsNotNull<Type>(type, \"type\");\n        Verify.IsNotNull<Type>(interfaceType, \"interfaceType\");\n        if (type.GetInterface(interfaceType.Name) == null)\n        {\n            throw new ArgumentException(\"The type of this parameter does not support a required interface\", parameterName);\n        }\n    }\n\n    [SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n    [DebuggerStepThrough]\n    public static void FileExists(string filePath, string parameterName)\n    {\n        Verify.IsNeitherNullNorEmpty(filePath, parameterName);\n        if (!File.Exists(filePath))\n        {\n            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, \"No file exists at \\\"{0}\\\"\", new object[]\n            {\n                filePath\n            }), parameterName);\n        }\n    }\n\n    [SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs#L188-L224","documentation":"Verify.TypeSupportsInterface checks that a Type argument implements a required interface using type.GetInterface(interfaceType.Name). It throws ArgumentException when the type does not expose an interface with the given name. Both arguments must be non-null (they are verified first).","triggerScenarios":"Passing a concrete Type (e.g. typeof(MyClass)) to an API expecting an implementer of a specific interface (e.g. ICommand or IWindowChrome), where the class does not implement it.","commonSituations":"Refactoring renames an interface or drops an implementation; passing a base class that lacks the interface that derived classes implement; type confusion between similarly named interfaces.","solutions":["Implement the required interface on the type, or pass a different type that implements it","Check beforehand with typeof(IRequired).IsAssignableFrom(type)","Verify the interface name matches exactly — GetInterface matches by name"],"exampleFix":"// before\napi.Check(typeof(MyClass), typeof(ICommand), \"type\"); // MyClass doesn't implement ICommand\n// after\npublic class MyClass : ICommand { /* implement members */ }\n// or guard:\nif (typeof(ICommand).IsAssignableFrom(typeof(MyClass))) api.Check(typeof(MyClass), typeof(ICommand), \"type\");","handlingStrategy":"type-guard","validationCode":"if (type == null) throw new ArgumentNullException(nameof(type));\nif (!interfaceType.IsAssignableFrom(type)) throw new ArgumentException($\"{type} does not implement {interfaceType}\", nameof(type));","typeGuard":"bool Implements(Type t, Type i) => t != null && i != null && i.IsAssignableFrom(t);","tryCatchPattern":"try { api.Call(type); } catch (ArgumentException ex) when (ex.Message.Contains(\"required interface\")) { /* fall back to a compatible type */ }","preventionTips":["Run interface conformance checks in unit tests after refactors","Prefer typeof(Iface).IsAssignableFrom(type) checks at call sites","Watch for renamed interfaces breaking name-based GetInterface lookups"],"tags":["type-check","interface","reflection"],"backgroundTag":"type-mismatch","analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}