Skip to content

Commit

Permalink
Report a critical error if signature is not found (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
masesdevelopers authored Sep 26, 2024
1 parent 438fe3f commit 8d3168a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/net/JNetReflector/InternalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,14 @@ public static string AddClassNameToSignature(this string methodSignature, string
return methodSignature;
}

public static string SignatureFromGenericString(this IReadOnlyDictionary<string, string> methodSignatures, string genString)
public static string SignatureFromGenericString(this IReadOnlyDictionary<string, string> methodSignatures, Method entry)
{
var filteredGenString = genString.RemoveThrowsAndCleanupSignature();
var filteredGenString = entry.GenericString.RemoveThrowsAndCleanupSignature();
string signature = null;
methodSignatures.TryGetValue(filteredGenString, out signature);
if (!methodSignatures.TryGetValue(filteredGenString, out signature))
{
ReflectionUtils.ReportTrace(ReflectionUtils.ReflectionTraceLevel.Critical, $"SignatureFromGenericString: signature not found for method {entry.Name} (Generic string: {entry.GenericString}) of class {entry.DeclaringClass.TypeName} using {filteredGenString} not found.");
}
return signature;
}

Expand Down
8 changes: 4 additions & 4 deletions src/net/JNetReflector/InternalMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void SetHandlerAndLevel(EventHandler<string> traceReport, int leve
Level = level;
}

static void ReportTrace(ReflectionTraceLevel level, string format, params object[] args)
internal static void ReportTrace(ReflectionTraceLevel level, string format, params object[] args)
{
if ((int)level > Level) return;
try
Expand Down Expand Up @@ -1423,7 +1423,7 @@ static string AnalyzeMethods(this Class classDefinition, IReadOnlyDictionary<str
StringBuilder executionStub = new StringBuilder();
if (getMethod != null)
{
string getSignature = methodsToSignature?.SignatureFromGenericString(getMethod.GenericString.RemoveThrowsAndCleanupSignature());
string getSignature = methodsToSignature?.SignatureFromGenericString(getMethod);
string execStub = getMethod.IsStatic() ? AllPackageClasses.ClassStub.MethodStub.STATIC_EXECUTE : AllPackageClasses.ClassStub.MethodStub.INSTANCE_EXECUTE;
if (!string.IsNullOrWhiteSpace(getSignature))
{
Expand All @@ -1448,7 +1448,7 @@ static string AnalyzeMethods(this Class classDefinition, IReadOnlyDictionary<str

if (setMethod != null)
{
string setSignature = methodsToSignature?.SignatureFromGenericString(setMethod.GenericString.RemoveThrowsAndCleanupSignature());
string setSignature = methodsToSignature?.SignatureFromGenericString(setMethod);
if (JNetReflectorCore.ReflectDeprecated) isSetDeprecated = setMethod.IsDeprecated();
string setExecStub = setMethod.IsStatic() ? AllPackageClasses.ClassStub.PropertyStub.STATIC_SET_EXECUTION_FORMAT : AllPackageClasses.ClassStub.PropertyStub.SET_EXECUTION_FORMAT;
var methodToCall = setMethod.IsStatic() ? AllPackageClasses.ClassStub.MethodStub.STATIC_EXECUTE : AllPackageClasses.ClassStub.MethodStub.INSTANCE_EXECUTE;
Expand Down Expand Up @@ -1509,7 +1509,7 @@ static string AnalyzeMethods(this Class classDefinition, IReadOnlyDictionary<str
var method = item.Value;
bool implementMethodAsListener = isDirectListener ? forListener : method.ToBeCallback(classDefinition, forListener);
var genString = method.GenericString;
string signature = methodsToSignature?.SignatureFromGenericString(genString);
string signature = methodsToSignature?.SignatureFromGenericString(method);
var paramCount = method.ParameterCount;
var methodNameOrigin = method.Name;
var eventHandlerName = methodNameOrigin;
Expand Down

0 comments on commit 8d3168a

Please sign in to comment.