File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
source/PythonNetStubGenerator Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -614,8 +614,28 @@ private static void WriteIEnumerableIterator(StringBuilder sb, Type stubType)
614614 }
615615
616616 private static bool IsPropertyAccessor ( MethodInfo it )
617- => it . IsSpecialName && ( it . Name . StartsWith ( "set_" ) || it . Name . StartsWith ( "get_" )
618- || it . Name . StartsWith ( "add_" ) || it . Name . StartsWith ( "remove_" ) ) ;
617+ {
618+ if ( ! it . IsSpecialName ) return false ;
619+ return IsPropertyGetterOrSetter ( it ) || IsEventAccessor ( it ) ;
620+ }
621+
622+ private static bool IsPropertyGetterOrSetter ( MethodInfo method )
623+ {
624+ // Property getters have zero parameters: get_PropertyName()
625+ // Property setters have exactly one parameter: set_PropertyName(value)
626+ // Regular methods like get_Parameter(BuiltInParameter) should NOT be filtered
627+ var paramCount = method . GetParameters ( ) . Length ;
628+ var isGetter = method . Name . StartsWith ( "get_" ) && paramCount == 0 ;
629+ var isSetter = method . Name . StartsWith ( "set_" ) && paramCount == 1 ;
630+ return isGetter || isSetter ;
631+ }
632+
633+ private static bool IsEventAccessor ( MethodInfo method )
634+ {
635+ // Event accessors (add_/remove_) always have exactly 1 parameter (the handler)
636+ var isEventMethod = method . Name . StartsWith ( "add_" ) || method . Name . StartsWith ( "remove_" ) ;
637+ return isEventMethod && method . GetParameters ( ) . Length == 1 ;
638+ }
619639
620640 private static bool NeedsMethodGroup ( List < MethodInfo > methods )
621641 => ( ! methods . Any ( IsOperator ) && methods . Count > 1 ) || methods . Any ( it => it . IsGenericMethodDefinition ) ;
You can’t perform that action at this time.
0 commit comments