private void processClassMethods ( XMLStreamWriter writer , Class < ? > aClass , Set < Method > methodSet ) throws XMLStreamException { Method [ ] methods = aClass . getDeclaredMethods ( ) ; for ( Method method : methods ) { if ( ! methodSet . contains ( method ) && Modifier . isPublic ( method . getModifiers ( ) ) && ! Modifier . isInterface ( method . getModifiers ( ) ) ) { if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { // TODO Handle static methods here } else { String name = method . getName ( ) ; String methodSignature = createMethodSignature ( method ) ; String fullJavaName = aClass . getCanonicalName ( ) + "." + name + methodSignature ; if ( ! ignoreMethod ( fullJavaName ) ) { // // Hide the original method // writer . writeStartElement ( "method" ) ; writer . writeAttribute ( "name" , name ) ; writer . writeAttribute ( "sig" , methodSignature ) ; writer . writeStartElement ( "attribute" ) ; writer . writeAttribute ( "type" , "System.ComponentModel.EditorBrowsableAttribute" ) ; writer . writeAttribute ( "sig" , "(Lcli.System.ComponentModel.EditorBrowsableState;)V" ) ; writer . writeStartElement ( "parameter" ) ; writer . writeCharacters ( "Never" ) ; writer . writeEndElement ( ) ; writer . writeEndElement ( ) ; writer . writeEndElement ( ) ; // // Create a wrapper method // name = name . toUpperCase ( ) . charAt ( 0 ) + name . substring ( 1 ) ; writer . writeStartElement ( "method" ) ; writer . writeAttribute ( "name" , name ) ; writer . writeAttribute ( "sig" , methodSignature ) ; writer . writeAttribute ( "modifiers" , "public" ) ; writer . writeStartElement ( "body" ) ; for ( int index = 0 ; index <= method . getParameterTypes ( ) . length ; index ++ ) { if ( index < 4 ) { writer . writeEmptyElement ( "ldarg_" + index ) ; } else { writer . writeStartElement ( "ldarg_s" ) ; writer . writeAttribute ( "argNum" , Integer . toString ( index ) ) ; writer . writeEndElement ( ) ; } } writer . writeStartElement ( "callvirt" ) ; writer . writeAttribute ( "class" , aClass . getName ( ) ) ; writer . writeAttribute ( "name" , method . getName ( ) ) ; writer . writeAttribute ( "sig" , methodSignature ) ; writer . writeEndElement ( ) ; if ( ! method . getReturnType ( ) . getName ( ) . equals ( "void" ) ) { writer . writeEmptyElement ( "ldnull" ) ; writer . writeEmptyElement ( "pop" ) ; } writer . writeEmptyElement ( "ret" ) ; writer . writeEndElement ( ) ; writer . writeEndElement ( ) ; /* * The private method approach doesn't work... so * 3. Add EditorBrowsableAttribute (Never) to original methods * 4. Generate C Sharp and VB variants of the DLL to avid case-sensitivity issues * 5. Implement static method support? <attribute type="System.ComponentModel.EditorBrowsableAttribute" sig="(Lcli.System.ComponentModel.EditorBrowsableState;)V"> 914 <parameter>Never</parameter> 915 </attribute> */ m_responseList . add ( fullJavaName ) ; } } } } }
Hides the original Java - style method name using an attribute which should be respected by Visual Studio the creates a new wrapper method using a . Net style method name .