Skip to content

Commit

Permalink
#426 (comment): Review how to identify listeners (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers authored Jun 3, 2024
1 parent f6b381f commit 728b42e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/net/JNetReflector/InternalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ public static string JVMInterfaceName(this Java.Lang.Reflect.Type type, IList<Ke

public static bool IsJVMListenerClass(this Java.Lang.Reflect.Type type)
{
return type.TypeName.IsJVMListenerClass();
var typeStr = type.TypeName;
typeStr = typeStr.Contains('<') ? typeStr.Substring(0, typeStr.IndexOf('<')) : typeStr;
return typeStr.IsJVMListenerClass();
}

public static string Type(this Java.Lang.Reflect.Type type, Class clazz, IList<string> genArguments, IList<KeyValuePair<string, string>> genClauses, string prefix, bool usedInGenerics, bool camel)
Expand Down Expand Up @@ -1167,9 +1169,9 @@ public static string JVMSimpleClassName(this Class entry)
public static string JVMListenerClassName(this Class entry)
{
var cName = entry.Name;
var packageName = (entry.Package != null && !string.IsNullOrWhiteSpace(entry.Package.Name)) ? entry.Package.Name
var packageName = (entry.Package != null && !string.IsNullOrWhiteSpace(entry.Package.Name)) ? entry.Package.Name
: string.Empty;
cName = (!string.IsNullOrWhiteSpace(packageName) && cName.StartsWith(packageName)) ? cName.Remove(0, packageName.Length + 1)
cName = (!string.IsNullOrWhiteSpace(packageName) && cName.StartsWith(packageName)) ? cName.Remove(0, packageName.Length + 1)
: cName;
cName = cName.Replace(SpecialNames.NestedClassSeparator, SpecialNames.ListenerNestedClassSeparator);
return cName;
Expand Down Expand Up @@ -1200,7 +1202,7 @@ public static string WhereClauses(this Class entry, bool usedInGenerics, bool ca
if (!IsJVMNativeType(bound.TypeName))
{
string result;
if (entry.IsJVMGenericClass() && usedInGenerics
if (entry.IsJVMGenericClass() && usedInGenerics
&& (entry.TypeName == bound.TypeName || bound.TypeName.StartsWith(entry.TypeName)))
{
// force the generic class in this case
Expand Down Expand Up @@ -1388,7 +1390,7 @@ public static string JVMBaseClassName(this Class entry, bool usedInGenerics, boo
|| (JNetReflectorCore.ReflectDeprecated ? false : superCls.IsDeprecated())
|| superCls.MustBeAvoided()
|| superCls.TypeName == SpecialNames.JavaLangObject)
{
{
if ((superCls == null || superCls.TypeName == SpecialNames.JavaLangObject) && entry.ContainsIterable())
{
string innerName = string.Empty;
Expand Down Expand Up @@ -2396,9 +2398,9 @@ public static bool IsReturnTypeAListener(this Method entry, bool usedInGenerics)
{
return entry.ReturnType.IsJVMListenerClass();
}
else if (!entry.GenericReturnType.IsGenerics())
else if (entry.GenericReturnType.IsGenerics())
{
return true;
return entry.GenericReturnType.IsJVMListenerClass();
}
return false;
}
Expand Down

0 comments on commit 728b42e

Please sign in to comment.