Skip to content

Commit 16b5f1c

Browse files
committed
Refactor README.md
1 parent 613907a commit 16b5f1c

1 file changed

Lines changed: 7 additions & 29 deletions

File tree

README.md

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Features
1818
* Generate C# XML comments from schema annotations
1919
* Generate [DataAnnotations](http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.aspx) attributes
2020
from schema restrictions
21+
* Generate custom attributes for schema restrictions that aren't covered by standard DataAnnotations (see [below](#restriction-attributes))
2122
* Use [`Collection<T>`](http://msdn.microsoft.com/en-us/library/ms132397.aspx) properties
2223
(initialized in constructor and with private setter)
2324
* Map xs:integer and derived types to the closest possible .NET type, if not possible - fall back to string. Can be overriden by explicitly defined type (int, long, or decimal)
@@ -247,35 +248,6 @@ var generator = new Generator
247248
};
248249
```
249250

250-
### Metadata attributes
251-
252-
When `EmitMetadataAttributes` is enabled, the generator emits custom attributes for XML schema restrictions that aren't covered by standard DataAnnotations. For example, `xs:fractionDigits` becomes `FractionDigitsAttribute`:
253-
254-
**Schema:**
255-
```xml
256-
<xs:element name="price">
257-
<xs:simpleType>
258-
<xs:restriction base="xs:decimal">
259-
<xs:fractionDigits value="2"/>
260-
</xs:restriction>
261-
</xs:simpleType>
262-
</xs:element>
263-
```
264-
265-
**Command line:**
266-
```
267-
xscgen --ema --mn MyApp.Metadata -o Generated schema.xsd
268-
```
269-
270-
**Generated code:**
271-
```C#
272-
[System.ComponentModel.DataAnnotations.Required()]
273-
[MyApp.Metadata.FractionDigits(2)]
274-
public decimal Price { get; set; }
275-
```
276-
277-
The attribute definition is automatically generated in the specified namespace. If not specified, the default namespace is `XmlSchemaClassGenerator.Metadata`.
278-
279251
### Mapping xsd files to C# namespaces
280252

281253
Using the optional `|` syntax of the `-n` command line option you can map individual xsd files to C# namespaces. If you have several input files using the same XML namespace you can still generate an individual C# namespace for the types defined within a single xsd file. For example, if you have two input files `a.xsd` and `b.xsd` both of which have the same `targetNamespace` of `http://example.com/namespace` you can generate the C# namespaces `Example.NamespaceA` and `Example.NamespaceB`:
@@ -507,6 +479,12 @@ are all integer types, then the narrowest integer type will be used that can fit
507479

508480
Note that semantic issues might arise with this approach. For example, `DateTime` values are serialized with both date and time information included. See discussion at [#397](https://github.com/mganss/XmlSchemaClassGenerator/issues/397).
509481

482+
### Restriction attributes
483+
484+
When `EmitMetadataAttributes` is enabled, the generator emits custom attributes for XML schema restrictions that aren't covered by standard DataAnnotations. For example, `xs:fractionDigits` becomes `FractionDigitsAttribute`.
485+
486+
The attribute definition is automatically generated in the namespace specified through `--metadataNamespace`. If not specified, the default namespace is `XmlSchemaClassGenerator.Metadata`.
487+
510488
Contributing
511489
------------
512490

0 commit comments

Comments
 (0)