luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.
MIT License
570 stars 109 forks source link

Exception thrown while generating bindings #48

Open frabert opened 7 years ago

frabert commented 7 years ago

I've been recently trying to generate bindings without success, as BindingsGen tries to load DTDs from the wrong paths apparently:

System.IO.FileNotFoundException occurred
  HResult=0x80070002
  Message=Impossibile trovare il file 'D:\Documenti\GitHub\OpenGL.Net\RefPages\EN'.
  Source=mscorlib
  StackTrace:
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   at BindingsGen.RegistryDocumentationHandler.LocalXhtmlXmlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) in D:\Documenti\GitHub\OpenGL.Net\BindingsGen\RegistryDocumentationHandler.cs:line 358
   at System.Xml.XmlTextReaderImpl.OpenAndPush(Uri uri)
   at System.Xml.XmlTextReaderImpl.PushExternalEntityOrSubset(String publicId, String systemId, Uri baseUri, String entityName)

The DTD in question is {file:///D:/Documenti/GitHub/OpenGL.Net/BindingsGen/bin/Debug/-/OASIS/DTD DocBook V4.2/EN} according to the debugger.

frabert commented 7 years ago

I have worked around the problem by editing the offending line:

- return (new FileStream(Path.Combine(DocumentPath, localPath), FileMode.Open, FileAccess.Read));
+ return null;
luca-piccioni commented 7 years ago

Just cloned and run BindingsGen in Release and Debug. Everything is fine on my machine (TM).

The patch won't prevent the documentation generation? Alternatively, you can get rid of GL2 and GLES1 reference pages: it will improve memory footprint and performance.

Still wonder why your instance is failing. Are you sure to be in sync with master/head? I've already seen that exception in the past (static readonly string BasePath = "../../..").

frabert commented 7 years ago

I have just deleted my local repository and starting from scratch to eliminate all possible factors. Anyway, I saw quite a large consumption of memory while generating the bindings (> 4GB), it went down to about 200MB after bypassing the whole GetEntity method). What is this method supposed to do? I could only understand that it obtains the DTDs necessary for validation of the XMLs' file schemas, but I might be mistaken...

EDIT: I will report when the process is done

luca-piccioni commented 7 years ago

GL2 and GLES1 reference pages have MathML (mml) namespaces that are not recognized if DTD parsing is not enabled. If you find a way to load documentation without DTD processing you'll make me a big favor (it consume so much memory).

Everything can be optimized, since the GL2 and GLES1 XML documents are cached (infact they are occupying all that memory): it will be sufficient to cache only the required documentation.

About GetEntity... I don't remember exactly, but essentially allows DTD processing from XmlDocument, using local DTDs. If you disable it (by returning null), no XML documentation is loaded.

(In the meanwhile, your exception has gone?)

frabert commented 7 years ago

The exception remains, unfortunately... Anyway, I will just disable the entity management for now since I do not need the docs to test the thing I am working on. I have found this though: AngleSharp. It looks like it may do the trick, since it supports XML loading without validation. I will look into it when I am done the other thing I am working on.