-
Notifications
You must be signed in to change notification settings - Fork 181
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
Private Member Fields Missing due to Duplicate/Overlapping Name #374
Comments
I've pushed a rather hacky fix to the |
That was quick, thanks! I will test it in the beginning of next week and will let you know how it looks like. Regards, |
It seems the issue still persists. By quickly looking at your changes I can unfortunately not see what exactly is happening, I think I would have to debug step by step to get an understanding for myself :) For me it seems that it should create Assuming it would be working and my assumption is correct, it might still be hard to guess that e.g. I also have to keep in mind that we are not solving my specific case, but that we need a more general solution. So please do not hesitate to let me know if my suggestions are too specific :) |
Yes, it should create Currently, the property names are disambiguated using a generic algorithm. Let's get this to work first for your use case, then try and make the naming more specific. Can you attach a sample schema here? |
Unfortunately I cannot provide the original files, but I created a minimal example for reproducing the issue. First, I wanted to give a step-by-step manual for how to produce the output files, but I do not get the tool to work on macOS with an M1* ARM processor. I can build and install the tool, however, when running the last command Unhandled exception. System.UnauthorizedAccessException: Access to the path 'XXX' is denied.
---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.FinishInitUriString()
at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings)
at XmlSchemaClassGenerator.Generator.<>c__DisplayClass144_0.<Generate>b__0(String f) in C:\projects\xmlschemaclassgenerator\XmlSchemaClassGenerator\Generator.cs:line 330
at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
at XmlSchemaClassGenerator.Generator.Generate(IEnumerable`1 files) in C:\projects\xmlschemaclassgenerator\XmlSchemaClassGenerator\Generator.cs:line 343
at XmlSchemaClassGenerator.Console.Program.Main(String[] args) in C:\projects\xmlschemaclassgenerator\XmlSchemaClassGenerator.Console\Program.cs:line 238
[1] 86245 abort xscgen main-schema.xsd . Weirdly, there is a Windows path printed. I have no idea where
And here the minimal files for reproducing the issue:
<xs:schema xmlns="http://github.com/schemas"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:T0050="https://github.com/template/T0050"
xmlns:T0051="https://github.com/template/T0051"
xmlns:T0052="https://github.com/template/T0052"
targetNamespace="http://github.com/schemas"
elementFormDefault="qualified"
version="1.0">
<xs:import namespace="https://github.com/template/T0050" schemaLocation="schema_T0050.xsd"/>
<xs:import namespace="https://github.com/template/T0051" schemaLocation="schema_T0051.xsd"/>
<xs:import namespace="https://github.com/template/T0052" schemaLocation="schema_T0052.xsd"/>
<xs:element name="output">
<xs:complexType>
<xs:sequence>
<xs:element name="document" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="T0050:documentpart" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="T0051:documentpart" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="T0052:documentpart" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://github.com/template/T0050"
elementFormDefault="qualified">
<xs:element name="documentpart">
<xs:complexType>
<xs:attribute name="templateid" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="4"/>
<xs:pattern value="0050"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://github.com/template/T0051"
elementFormDefault="qualified">
<xs:element name="documentpart">
<xs:complexType>
<xs:attribute name="templateid" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="4"/>
<xs:pattern value="0010"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://github.com/template/T0052"
elementFormDefault="qualified">
<xs:element name="documentpart">
<xs:complexType>
<xs:attribute name="templateid" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="4"/>
<xs:pattern value="0020"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema> |
Thanks for creating the example schemas. Regarding the exception I have a feeling that it's a permissions issue. The It works for me using the schemas above. I see 3 private fields named |
Hm, maybe that is indeed the case that I am actually installing the version from NuGet. Actually a bit stupid of me for not checking the version after the installation... (I was very distracted with some weird macOS permission issues :o) However, as you tested with the files above, we know that your branch fixes the issue. So I'd say let's ignore the problem on my side because I doubt it will add any further value to your fix. As an information, we also tried the official Thanks four your time! I just saw you are also involved in the |
I've merged the branch. Closing this for now. |
Given the sequence:
This leads to the problem that the private member field is named
_document
for all threeT*
namespaces (so the namespace name is not included). This results in only the first T-entryT001
(and the A entry) are to be found in the generated C# class file.Is this a know issue and / or any way for a workaround?
If it is a known issue but no fix is yet available, can you point me to where in the code I find the private member name generation? I think it would be useful to somehow include the namespace in the member name to prevent this issue. I suppose this might introduce additional issues as the namespace can probably begin with characters which are not allowed in C#.
Would be grateful for any input on this as we really would like to use this tool for a larger project where we unfortunately are encountering this issue.
Thanks in advance,
flennic
The text was updated successfully, but these errors were encountered: