diff --git a/tools/generator/CodeGeneratorContext.cs b/tools/generator/CodeGeneratorContext.cs index c91e58769..87a321500 100644 --- a/tools/generator/CodeGeneratorContext.cs +++ b/tools/generator/CodeGeneratorContext.cs @@ -16,5 +16,17 @@ public class CodeGeneratorContext string ContextMethodString => ContextMethod != null ? "in method " + ContextMethod.Name + " " : null; string ContextTypeString => ContextType != null ? "in managed type " + ContextType.FullName : null; public string ContextString => ContextFieldString + ContextMethodString + ContextTypeString; + + public string GetContextTypeMember () + { + var output = ContextType?.FullName ?? string.Empty; + + if (ContextMethod != null) { + output += $"{ContextMethod.Name} ({string.Join (", ", ContextMethod?.Parameters.Select (p => p.InternalType).ToArray ())})"; + return output; + } + + return output + ContextField?.Name; + } } } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Field.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Field.cs index be75bbb2a..8dd82cbe2 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Field.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Field.cs @@ -38,7 +38,7 @@ public bool Validate (CodeGenerationOptions opt, GenericParameterDefinitionList Symbol = opt.SymbolTable.Lookup (TypeName, type_params); if (Symbol == null || !Symbol.Validate (opt, type_params, context)) { - Report.LogCodedWarning (0, Report.WarningUnexpectedFieldType, TypeName, context.ContextString); + Report.LogCodedWarning (0, Report.WarningUnexpectedFieldType, TypeName, context.GetContextTypeMember ()); return false; } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenericParameterDefinition.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenericParameterDefinition.cs index d98f88634..9cf846206 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenericParameterDefinition.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenericParameterDefinition.cs @@ -38,7 +38,7 @@ public bool Validate (CodeGenerationOptions opt, GenericParameterDefinitionList foreach (var c in ConstraintExpressions) { var sym = opt.SymbolTable.Lookup (c, type_params); if (sym == null) { - Report.LogCodedWarning (0, Report.WarningUnknownGenericConstraint, c, context.ContextString); + Report.LogCodedWarning (0, Report.WarningUnknownGenericConstraint, c, context.GetContextTypeMember ()); validated = true; return false; } diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Parameter.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Parameter.cs index c4ff3c7c2..19c4bb9ce 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Parameter.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/Parameter.cs @@ -224,6 +224,8 @@ public string Type { get { return managed_type ?? sym.FullName; } } + public string InternalType => managed_type ?? sym?.FullName ?? type; + public string Annotation { get; internal set; } public void SetGeneratedEnumType (string enumType) @@ -260,11 +262,11 @@ public bool Validate (CodeGenerationOptions opt, GenericParameterDefinitionList { sym = opt.SymbolTable.Lookup (type, type_params); if (sym == null) { - Report.LogCodedWarning (0, Report.WarningUnknownParameterType, type, context.ContextString); + Report.LogCodedWarning (0, Report.WarningUnknownParameterType, type, context.GetContextTypeMember ()); return false; } if (!sym.Validate (opt, type_params, context)) { - Report.LogCodedWarning (0, Report.WarningInvalidParameterType, type, context.ContextString); + Report.LogCodedWarning (0, Report.WarningInvalidParameterType, type, context.GetContextTypeMember ()); return false; } return true; diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ReturnValue.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ReturnValue.cs index 484e537ca..a25eb6489 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ReturnValue.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ReturnValue.cs @@ -121,11 +121,11 @@ public bool Validate (CodeGenerationOptions opt, GenericParameterDefinitionList { sym = (IsEnumified ? opt.SymbolTable.Lookup (managed_type, type_params) : null) ?? opt.SymbolTable.Lookup (java_type, type_params); if (sym == null) { - Report.LogCodedWarning (0, Report.WarningUnknownReturnType, java_type, context.ContextString); + Report.LogCodedWarning (0, Report.WarningUnknownReturnType, java_type, context.GetContextTypeMember ()); return false; } if (!sym.Validate (opt, type_params, context)) { - Report.LogCodedWarning (0, Report.WarningInvalidReturnType, java_type, context.ContextString); + Report.LogCodedWarning (0, Report.WarningInvalidReturnType, java_type, context.GetContextTypeMember ()); return false; } return true;