New Post: VS2015 support
Created Unassigned: Disable FieldGenereation when using AutomaticProperties = True [17167]
It works great, but when i enable the Feature PropertyParams => AutomaticProperties = True
with Code =>TargetFramework = Net40 and Behavior =>EnableDataBinding = false.
xsd2Code still generates FieldProperties, wich are unable to be reached by code.
Could you please fix this issue, because it creates noise in the generated classes and obfuscates my pocos.
sample:
```
public partial class Plan {
private System.DateTime endTimeField;
private long fromStepPlanIdField;
private System.DateTime startTimeField;
private long toStepPlanIdField;
private long transitionPlanIdField;
public System.DateTime endTime {get; set;}
public long fromStepPlanId {get; set;}
public System.DateTime startTime {get; set;}
public long toStepPlanId {get; set;}
public long transitionPlanId {get; set;}
}
```
Kind Regars
Pascal
Commented Unassigned: Disable FieldGenereation when using AutomaticProperties = True [17167]
It works great, but when i enable the Feature PropertyParams => AutomaticProperties = True
with Code =>TargetFramework = Net40 and Behavior =>EnableDataBinding = false.
xsd2Code still generates FieldProperties, wich are unable to be reached by code.
Could you please fix this issue, because it creates noise in the generated classes and obfuscates my pocos.
sample:
```
public partial class Plan {
private System.DateTime endTimeField;
private long fromStepPlanIdField;
private System.DateTime startTimeField;
private long toStepPlanIdField;
private long transitionPlanIdField;
public System.DateTime endTime {get; set;}
public long fromStepPlanId {get; set;}
public System.DateTime startTime {get; set;}
public long toStepPlanId {get; set;}
public long transitionPlanId {get; set;}
}
```
Kind Regars
Pascal
Comments: ** Comment from web user: mightymuke **
Is this the same issue as https://xsd2code.codeplex.com/workitem/15266
New Post: Is it possible to create an element with dynamic
<xs:complexType name="Achievement">
<xs:sequence>
<xs:element name="milestone" type="xs:dynamic" />
</xs:sequence>
</xs:complexType>
wich schould create a class likepublic partial class Achivement {
public dynamic milestone{ get; set; }
}
i could not find any samples on the web.New Post: Create a list for each element, instead of a single List of objects
Brand new to xsd@Code, and fairly new to XML serialization/deserialization in general. I'm working on a project where I need to convert a rather large xsd into a set of C# classes. xsd2Code created the classes wonderfully, and I have setup nearly to where I'd like it to be after fiddling with the settings.
The one thing that I'm unable to figure out how to do (if it can even be done) is to generate separate classes for each possible element within one element. xsd@Code generates a single List<object> Items for all possible elements by default. Is there a setting that would give me what I want?
So, for example, I would have something similar to the below generated (along with the initializers in the constructor):
[XmlElementAttribute("foo", typeof(foo))]
public List<condition> Foos{ get; set; }
[XmlElementAttribute("bar", typeof(bar))]
public List<navigation> Bars{ get; set; }
[XmlElementAttribute("fooBar", typeof(fooBar))]
public List<presentation> FooBars{ get; set; }
/// <summary>
/// FooBarParent class constructor
/// </summary>
public FooBarParent()
{
Foos= new List<foo>();
Navigations = new List<bar>();
FooBars= new List<fooBar>();
}
instead of them all being placed into the single list of generic objects, like the below. [XmlElementAttribute("foo", typeof(foo))]
[XmlElementAttribute("bar", typeof(bar))]
[XmlElementAttribute("fooBar", typeof(fooBar))]
public List<object> Items{ get; set; }
/// <summary>
/// FooBarParent class constructor
/// </summary>
public FooBarParent()
{
Items= new List<object>();
}
I can go and alter the code, but there are a few thousand different element types I need to deal with, so I'd rather have something auto generated if possible.Thanks!
Patch Uploaded: #17046
J4son has uploaded a patch.
Description:
* Added option ExcludeChoiceElements (Under property params) that allows you to either add an XmlIgnore attribute to choice elements or completely remove them. This is so you can provide the functionality yourself in a partial.
* Added Option to EnableInitialiseFields to only initialise collections.
* Fixed an issue where backing field didn't get removed when property converted to auto property.
* Made Library visible to UnitTest project (added key) so that unit tests could just test the CodeDom.
Created Unassigned: nullable enum issue [17250]
<xs:element name="FrequencyCode" type="FrequencyCodeType" minOccurs="0"></xs:element>
<xs:simpleType name="FrequencyCodeType">
<xs:restriction base="xs:string">
<xs:enumeration value="AA"/>
<xs:enumeration value="BB"/>
</xs:restriction>
</xs:simpleType>
This generates the following code. As you can see, it's impossible to get a null from the FrequencyCode property because it always returns the default.
```
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public enum FrequencyCodeType
{
AA,
BB
}
private System.Nullable<FrequencyCodeType> _frequencyCode
public FrequencyCodeType FrequencyCode
{
get
{
if (this._frequencyCode.HasValue)
{
return this._frequencyCode.Value;
}
else
{
return default(FrequencyCodeType);
}
}
set
{
this._frequencyCode= value;
}
}
```
New Post: Building a complete xml doc instantiating only one nested element
Vital_signs
Blood_pressure
Sistolic
Magnitude
Units
I would like to create a complete XML by filling in just the leaf elements and have the generated code deal with the creation of the superordinate elements, in such a way that on entering values for the leaf units I could obtain something like<Vital_Signs>
<Blood_pressure>
<Sistolic>
<Magnitude>120</Magnitude>
<Units>mmHg</Units>
</Sistolic>
</Blood_pressure><Vital_Signs>
But the fact is that if I invoke the xsd2code generated class Vital_SignsBlood_pressureSistolicMagnitude, instantiate the class and add a value, I get, as a result of serialization, something like
<Vital_SignsBlood_pressureSistolicMagnitude>120</Vital_SignsBlood_pressureSistolicMagnitude>
which isn't very useful.
In order to reproduce the whole xml structure I must create each class and include a created nested class in it, something which is quite complicated.
Is there something which might allow me to do something on the lines of
var vs = new Vital_signs();
vs.BloodPressure.Sistolic.Magnitude = 120;
vs.BloodPressure.Sistolic.Units = "mmHg";
the classes for which could be produced automatically?
I understand this might be difficult when it comes to adding lists and the like, but it would be most useful. Creating a class for every level is quite cumbersome in case of really big xsd's. There is probably some way of doing this which I am unaware of....is there?
Created Unassigned: Byte Order Marker - UTF8 Encoding failure [17295]
If you create your own UTF8Encoding class, it makes no difference what you set because of this shared property use.
Wrong:
```
streamWriter = New System.IO.StreamWriter(fileName, False, encoding.UTF8)
```
Corrected:
```
streamWriter = New System.IO.StreamWriter(fileName, False, encoding)
```
When checking that values, encoding.emitUTF8Identifier is false if you do encoding = new UTF8Encoding(false). However, encoding.UTF8.emitUTF8Idnetifier is true because calling UTF8 creates a shared version of its own.
Reviewed: xsd2code community edition 3.4 (Dec 28, 2014)
Commented Issue: StackOverflowException for Recursive Element [7419]
Here is a snippet from the schema:
<xsd:complexType name = "LocationType">
<xsd:sequence>
<xsd:element name = "EquipmentID" type="EquipmentIDType"/>
<xsd:element name = "EquipmentElementLevel" type="EquipmentElementLevelType"/>
<xsd:element name = "Location" type="LocationType" minOccurs="0"/>
<xsd:group ref = "Extended:Location" minOccurs="0" maxOccurs="1"/>
<!-- Added in V04 - The Any element should not be used in new schemas. This extension schema should be used to add user defined
elements to B2MML documents. In a future release the Any element will be removed from B2MML. -->
<xsd:element name = "Any" type="AnyType"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
Here is a snippet of generated code that has the exception:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3074")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.wbf.org/xml/B2MML-V0401")]
public partial class LocationType : System.ComponentModel.INotifyPropertyChanged
{
[EditorBrowsable(EditorBrowsableState.Never)]
private EquipmentIDType equipmentIDField;
[EditorBrowsable(EditorBrowsableState.Never)]
private EquipmentElementLevelType equipmentElementLevelField;
[EditorBrowsable(EditorBrowsableState.Never)]
private LocationType locationField;
[EditorBrowsable(EditorBrowsableState.Never)]
private List<AnyType> anyField;
public LocationType()
{
if ((this.anyField == null))
{
this.anyField = new List<AnyType>();
}
if ((this.locationField == null))
{
this.locationField = new LocationType();
}
if ((this.equipmentElementLevelField == null))
{
this.equipmentElementLevelField = new EquipmentElementLevelType();
}
if ((this.equipmentIDField == null))
{
this.equipmentIDField = new EquipmentIDType();
}
}
Comments: ** Comment from web user: allderidge **
I've added a post processing step after executing xsd2code (in a msbuild task) that strips out the construction of associated objects. The partial code is:
var codeFile = File.ReadAllText(InputCodeFile);
var regex = new Regex(@"this\.[A-Za-z][A-Za-z1-9.<>]* = new (?!ObservableCollection)[A-Za-z][A-Za-z1-9.<>]*\(\);");
codeFile = regex.Replace(codeFile, "");
This leaves the construction of object collections by preventing a match where a field initialises a new ObservableCollection (change to ObservableCollection to List so that the regex works with the default settings).
As an alternative you could add the option /if- (Disable all field initialization constructor or lazy) to the xsd2code command line, but this stops the collections fields from initialising so you can't write code: new Customer(); customer.Purchases.Add(new Purchase);
Commented Issue: Issue with XmlChoiceIdentifier and enums [9877]
I use the last version (3.0) and I have some big issues while creating XmlSerializer with classes generated from NewsML-G2 xsd files.
http://www.iptc.org/std/NewsML-G2/NewsML-G2_2.4.zip
During the runtime, when I create the serializer, a lot of innerexception leads to the exception:
"Type of choice identifier 'ItemElementName' is inconsisitent with type of 'Item'. Please use List<>... of <namespace>.ItemChoiceType."
The thing is that the XmlChoiceIdentifierAttribute is correctly ItemElementName, and the ItemElementName is of the list<ItemChoiceType>.
Then I try to generate the same class, but this type with arrays instead of List. Then it says:
"Type ItemsChoiceType is missing enumeration value 'Items' for element 'Items' from namespace ''.""
So ok, I tried to add Items in the enum, and it goes to the next issue which is the same but in another type.
I feel this is a mistake in the class generator, but I don't really understand why it needs the type Items in the enum? Is this a bug, a mistake in the schema?
Please help!
Comments: ** Comment from web user: Joetempes **
Can anybody send my a custom build of xsd2code, where is fixed this error?
New Post: Xsd2Code Deserialize problem
After setting XmlRoot on the class in question in the generated code to deal with a namespace problem, when I call LoadFromFile, I get back an object populated with nothing. No errors. Just a blank object where every field is 0 or null.
Can anyone suggest what might be happening here? With no error message and no code visibility, I'm left guessing.
Thanks.
New Post: Xsd2Code Deserialize problem
Created Unassigned: Rewrite XML file [17340]
I load data from the XML file to a object and want to save changes in that XML file.
What is the best way to rewrite the XML file after make changes in object (not to add).
thanks
Created Unassigned: Ability to set GenerateOrderXmlAttributes=false via command-line [17348]
If running via Visual studio interface, you can set GenerateOrderXmlAttributes to false to supress the generation of the Order element, but this option is not available via command-line.
(I am using version 3.4.0.32989)
Commented Issue: annotations as comments [11556]
Comments: ** Comment from web user: rolivares **
There is a problem, I have annotations into enum elements and are not been included into the generated code
New Post: Can it be used for inside of commercial applications?
I see that the license is MIT which makes me guess that yes, but I want to make sure.
Commented Issue: Issue with XmlChoiceIdentifier and enums [9877]
I use the last version (3.0) and I have some big issues while creating XmlSerializer with classes generated from NewsML-G2 xsd files.
http://www.iptc.org/std/NewsML-G2/NewsML-G2_2.4.zip
During the runtime, when I create the serializer, a lot of innerexception leads to the exception:
"Type of choice identifier 'ItemElementName' is inconsisitent with type of 'Item'. Please use List<>... of <namespace>.ItemChoiceType."
The thing is that the XmlChoiceIdentifierAttribute is correctly ItemElementName, and the ItemElementName is of the list<ItemChoiceType>.
Then I try to generate the same class, but this type with arrays instead of List. Then it says:
"Type ItemsChoiceType is missing enumeration value 'Items' for element 'Items' from namespace ''.""
So ok, I tried to add Items in the enum, and it goes to the next issue which is the same but in another type.
I feel this is a mistake in the class generator, but I don't really understand why it needs the type Items in the enum? Is this a bug, a mistake in the schema?
Please help!
Comments: ** Comment from web user: YDP **
I had the same problem when using the Bartender Seagull response schema's.
A workaround for me was:
- Put Serialization->GenerateXmlAtributes on
- Set CollectionObject Type to array
But still, this issue should be fixed in the component so we can use List in stead of arrays as collection object type.
New Post: Create a list for each element, instead of a single List of objects
<xs:complexType name="behavior">
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="event" type="Event" />
<xs:element name="data1" type="info" />
<xs:element name="data2" type="info" />
</xs:sequence>
</xs:complexType>
When I use one of my PC's with xsd2code 3.4 to build this code it generates 3 separate lists for event, data1 and data2.When I use a different PC with xsd2code 3.4 it generates a single list that can contain all three data types.
How can I specify the use of the first behavior only?
Regards, Mike!