File tree Expand file tree Collapse file tree
GameFrameX.Foundation.Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,11 +29,15 @@ public static partial class TypeExtensions
2929 /// 它会递归检查类型的继承链和接口实现。
3030 /// </remarks>
3131 /// <exception cref="ArgumentNullException">当<paramref name="targetType"/>或<paramref name="interfaceType"/>为null时抛出</exception>
32+ /// <exception cref="ArgumentException">当<paramref name="interfaceType"/>不是接口类型时抛出</exception>
3233 public static bool HasInterface ( Type targetType , Type interfaceType )
3334 {
34- if ( targetType == null || interfaceType == null || ! interfaceType . IsInterface )
35+ ArgumentNullException . ThrowIfNull ( targetType , nameof ( targetType ) ) ;
36+ ArgumentNullException . ThrowIfNull ( interfaceType , nameof ( interfaceType ) ) ;
37+
38+ if ( ! interfaceType . IsInterface )
3539 {
36- return false ;
40+ throw new ArgumentException ( LocalizationService . GetString ( LocalizationKeys . Exceptions . TargetTypeMustBeInterface ) , nameof ( interfaceType ) ) ;
3741 }
3842
3943 return interfaceType . IsAssignableFrom ( targetType ) ;
You can’t perform that action at this time.
0 commit comments