Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[generator] Fix exception caused by incorrect nested type name. (#1267)
Context: #1266 Context: #1268 While the issue described in #1266 is definitely an issue, that example was merely setting up the scenario needed to expose another bug: When a `Java.Lang.Object` or `Java.Interop.JavaObject` subclass has a `public` or `internal` field whose type is a nested type: // C# namespace Com.Mypackage; [Register ("com/mypackage/FieldClass")] public class FieldClass : Java.Lang.Object { public NestedFieldClass field; public class NestedFieldClass : Java.Lang.Object { } } We correctly import the `Field.TypeName` as `Com.Mypackage.FieldClass.NestedFieldClass`, however we also create `Field.SetterParameter` with the "same" type, but we do not replace the `/` nested type separator with a period, resulting in `Com.Mypackage.FieldClass/NestedFieldClass`. Later, when validating the `Field`, we successfully find `Field.TypeName` in the symbol table, but fail to find `Field.SetterParameter` as the symbol table expects a period nested type separator. (Note this only happens because `NestedFieldClass` does not have a `[Register]` attribute, thus it gets added to the symbol table with its managed name rather than its Java name.) This causes `generator` to crash with: System.NotSupportedException: Unable to generate setter parameter list in managed type Com.Mypackage.FieldClass at MonoDroid.Generation.Field.Validate(CodeGenerationOptions opt, GenericParameterDefinitionList type_params, CodeGeneratorContext context) at MonoDroid.Generation.GenBase.OnValidate(CodeGenerationOptions opt, GenericParameterDefinitionList type_params, CodeGeneratorContext context) at MonoDroid.Generation.ClassGen.OnValidate(CodeGenerationOptions opt, GenericParameterDefinitionList type_params, CodeGeneratorContext context) at MonoDroid.Generation.GenBase.Validate(CodeGenerationOptions opt, GenericParameterDefinitionList type_params, CodeGeneratorContext context) Fix this by applying the same `FullNameCorrected()` logic that is applied to `Field.TypeName`.
- Loading branch information