bfriesen / csharpinator Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Given a JSON document like this:
{
"ID": 1,
"PublishedAt": "\/Date(1330848000000-0800)\/",
"Text": "Best blog post ever",
"Title": "Magical Title"
}
It creates a class with property like this:
[DataContract]
public partial class Container
{
[IgnoreDataMember]
public DateTime PublishedAt { get; set; }
[DataMember(Name="PublishedAt")]
public string PublishedAtString
{
get
{
return PublishedAt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", new CultureInfo("en-US"));
}
set
{
PublishedAt = DateTime.ParseExact(value, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK", new CultureInfo("en-US"));
}
}
/* Other properties here */
}
It should create a class like this:
[DataContract]
public partial class Container
{
[DataMember(Name="PublishedAt")]
public DateTime PublishedAt { get; set; }
/* Other properties here */
}
Identifiers like THIS_THING
should end up like ThisThing
, thisThing
, or this_thing
(depending on the specific casing). They're currently ending up like THIS_THING
.
When you have a list of elements, they're not merging with each other during a single pass. A second pass fixes this.
Implementation brainstorming:
Example:
<container>
<foos>
<foo>abc</foo>
<foo>xyz</foo>
<bar>123</bar>
</foos>
</container>
Produced c# code:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Xml.Serialization;
namespace FooBar
{
[XmlRoot("container")]
public partial class Container
{
[XmlElement("foos")]
public Foos Foos { get; set; }
}
[XmlRoot("foos")]
public partial class Foos
{
[XmlElement("foo")]
public List<string> Foos { get; set; }
[XmlIgnore]
public int? Bar { get; set; }
[XmlElement("bar")]
public string BarString
{
get
{
return Bar == null ? null : Bar.ToString();
}
set
{
Bar = value == null ? null : (int?)int.Parse(value);
}
}
}
}
The problem is that class Foos has a property named Foos, which doesn't compile.
Given no refinements, an empty element should output a property of type string. Upon refinement (where the element has some kind of child(ren)), completely reevaluate the property.
Currently, it is required to process an document in order to generate classes. We need to be able to generated classes based purely on a previously-saved metadata file.
Add branching to code to detect each combination, throwing a NotImplementedException for cases that aren't implemented yet.
Given this input...
<foo foo_value="true">
<bar bar_value="123">abc</bar>
<bar bar_value="456">xyz</bar>
</foo>
Or this one...
<foo foo_value="true">
<bar bar_value="123">abc</bar>
</foo>
This class is being generated:
[XmlRoot("bar")]
public partial class Bar
{
}
The Bar class should have two properties: BarValue (of type int) and Value (of type string).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.