-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generator problems with new .NET types #34
Comments
Yeah.
I think we have issues with generic arrays
public ReadOnlyMemory (T[] array);
If you look in mscorlib.codegen.config.obj.xml:
<MemberNameSkipList>
<!-- Skip list for properties, fields and methods -->
<string>System.Array:Resize</string>
</MemberNameSkipList>
The signature for Resize() is:
public static void Resize<T> (ref T[] array, int newSize);
So the workaround is to add the method to the MemberNameSkipList.
Obviously it's a constructor, which could be a big issue if you need to instantiate it…
We generate the type info via reflection and write into an XML file.
Code generation is a separate step.
The XML file approach was used for several reasons:
1. the common type systems is reasonably complex and writing the type info out meant that we could easily review what type info was being used for a particular class/signature. This helped a lot when trying to get decent coverage for arrays, generics, by ref vars etc.
2. it means that we can regenerate the bindings without having to reflect every time.
The downside is that the code generator it self cannot reflect directly on a given type if it needs some extra type info.
So to handle these more complex signatures:
1. figure out what extra managed type info is required and write it out to the XML file.
2. figure out how to generate the required Obj-C sig based on the extra XML data gets presented in a Facet object.
The code generator logic is quite twisty but I imagine this is doable.
Another approach would be to ditch the XML and do the reflection in the generator - but that sounds like a big refactor.
… On 10 Dec 2019, at 08:37:27, Felix Deimel ***@***.***> wrote:
The generator currently has problems with certain new types in the Mono framework like System.ReadOnlyMemory.
Here's a sample stack trace:
System.Exception: System_ReadOnlyMemoryA1[T] is not a valid ObjC identifier
at Dubrovnik.Tools.Facets.CodeFacet.ObjCIdentifierFromManagedIdentifier (System.String managedIdentifier) [0x000f0] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.Facets.CodeFacet..ctor (Dubrovnik.Tools.Facets.CodeFacet facet) [0x00021] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.Facets.CodeFacet..ctor (System.Xml.Linq.XElement xelement) [0x0024c] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.Facets.ParameterFacet..ctor (System.Xml.Linq.XElement xelement) [0x00000] in <3d489b2013324dc78b323a9d3008a96c>:0
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <ba70b91736bd40cb990a357097dba9c3>:0
--- End of inner exception stack trace ---
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x0001a] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00086] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x0022b] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x0009c] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <ba70b91736bd40cb990a357097dba9c3>:0
at Dubrovnik.Tools.Facets.FacetList`1[TFacet]..ctor (System.Xml.Linq.XElement parent, System.String childname, Dubrovnik.Tools.Facets.CodeFacet Parent) [0x0004b] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.Facets.MethodFacet..ctor (System.Xml.Linq.XElement xelement) [0x00009] in <3d489b2013324dc78b323a9d3008a96c>:0
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <ba70b91736bd40cb990a357097dba9c3>:0
--- End of inner exception stack trace ---
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x0001a] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00086] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x0022b] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x0009c] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <ba70b91736bd40cb990a357097dba9c3>:0
at Dubrovnik.Tools.Facets.FacetList`1[TFacet]..ctor (System.Xml.Linq.XElement parent, System.String childname, Dubrovnik.Tools.Facets.CodeFacet Parent) [0x0004b] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.Facets.InterfaceFacet..ctor (System.Xml.Linq.XElement xelement) [0x0002f] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.Facets.ClassFacet..ctor (System.Xml.Linq.XElement xelement) [0x00000] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.Facets.StructFacet..ctor (System.Xml.Linq.XElement xelement) [0x00000] in <3d489b2013324dc78b323a9d3008a96c>:0
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <ba70b91736bd40cb990a357097dba9c3>:0
--- End of inner exception stack trace ---
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x0001a] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00086] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x0022b] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x0009c] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <ba70b91736bd40cb990a357097dba9c3>:0
at Dubrovnik.Tools.Facets.FacetList`1[TFacet]..ctor (System.Xml.Linq.XElement parent, System.String childname, Dubrovnik.Tools.Facets.CodeFacet Parent) [0x0004b] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.Facets.NamespaceFacet..ctor (System.Xml.Linq.XElement xelement) [0x00042] in <3d489b2013324dc78b323a9d3008a96c>:0
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <ba70b91736bd40cb990a357097dba9c3>:0
--- End of inner exception stack trace ---
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x0001a] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00086] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x0022b] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x0009c] in <ba70b91736bd40cb990a357097dba9c3>:0
at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <ba70b91736bd40cb990a357097dba9c3>:0
at Dubrovnik.Tools.Facets.FacetList`1[TFacet]..ctor (System.Xml.Linq.XElement parent, System.String childname, Dubrovnik.Tools.Facets.CodeFacet Parent) [0x0004b] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.Facets.AssemblyFacet..ctor (System.Xml.Linq.XElement xelement) [0x00009] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Tools.CodeGenerator.Execute () [0x0000c] in <3d489b2013324dc78b323a9d3008a96c>:0
at Dubrovnik.Generator.Program.Main (System.String[] args) [0x000df] in <20348a9d193143c0a91eb30f8671f2e9>:0
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The generator currently has problems with certain new types in the Mono framework like
System.ReadOnlyMemory
.Here's a sample stack trace:
The text was updated successfully, but these errors were encountered: