Conversation
|
So it looks like we will have a unique problem - the /// <summary>
/// An item being offered (or demanded). The transactional nature of the offer or demand is documented using <a class="localLink" href="http://schema.org/businessFunction">businessFunction</a>, e.g. sell, lease etc. While several common expected types are listed explicitly in this definition, others can be used. Using a second type, such as Product or a subtype of Product, can clarify the nature of the offer.
/// </summary>
Values<IAggregateOffer, ICreativeWork, IEvent, IMenuItem, IProduct, IService, ITrip> ItemOffered { get; set; }I think we're gonna need to make a My thought is rather than maintain all of these |
|
The order of some inherited interfaces changed which caused some noise in the generated code. If we ordered them by name, we could solve that problem in future at the expense of a one time noisy commit. Not sure about generating |
Yeah, that's a fair call. Might be worth doing as a separate PR to this after this is merged. That said, I know we have a little bit of logic in the
I'm just thinking the overhead of manually updating Not sure what we would do for the tests though - would be kinda silly to automatically generate tests for it as we would have potential for the tests themselves to be wrong. |
|
Good point about tests. Feels a bit weird but then generating code using StringBuilder feels weird too. Have you seen the news about code generation in .NET? Early days but they plan to add code generation as a 1st class feature. They talk about a pre-compile step where code-gen code in your method is run and then spits out autogenerated code. We might be able to use that when it's more concrete. |
|
Sorry, I've been meaning to get back to this for a while - I've looked up a few solutions that we could use now however they have different pros/cons: T4 Templates
CodeDOM
I think with the right helper methods, we could make a solution with CodeDOM work pretty well and not be too much of a burden to the code base. This tutorial from MS would be a good start: https://docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/how-to-create-a-class-using-codedom We should be able to generate code that is 100% compatible with the editor config rules etc so we don't need to deal with any weirdness. |
|
While not in the scope of this PR, if we did want to migrate away from using the |
|
I'm hesitant to invest heavily in code generation when I know that Microsoft is building something as we speak. The thing is I'm not certain when that will become available. At this stage it's all experimental. If I had to guess, it'd take at least several months. |
|
Lets just fix up the CI and get this merged for now. Schema.org v7 came out with some Corona Virus updates. Might be worth getting that in too. |
|
I've added support for Values7 (that took a long while to write all the tests). Looks to now be just breaking changes with some of the other models and their tests. |
|
Looks like there are 6 failed tests. Thanks for updating. It'd be nice to stick it to the CoronaVirus in a very very small way with this PR. |
ISO 8601 defines the offset as numbers after a "+" as the offset or after a "Z" meaning UTC0. Without this change, the timezone offset of the current machine is used which is (in many cases) undesired.
|
So the fix for those tests was a slight change to how we handle For a Some To alleviate this, I made the check to try parsing as a |
|
There are a few quirks with what I've mentioned above so will be adding some tests and tweaking some more behaviour. |
|
One obvious mistake I missed, I'm not handling negative offsets. Whoops! |
|
I'm going down a rabbit hole of little issues. The short of it is, I'm going to disable the built-in Using this The reason these changes belong in this PR is that my first "fix" for the tests, while passes, actually fails at the few additional tests I'm adding around those changes. I'd rather have a properly tested and functional PR than split a half-working PR into two PRs. |
|
To summarise everything:
Its that last part which brings through these changes:
With that last point, it means we are no longer skipping one of our tests for MS DateTime. |
|
Oh, one other little note - I added an allocation free path using |
|
Looks reasonable to me. I'll see if I can arrange a release today. Thanks for your efforts as usual. Stay safe! |
|
@Turnerj Source generators is here now. It came earlier than I expected. |
|
Yeah it sounds interesting though I'm not actually sure its going to be much of a difference for this library. As the source is injected into the build, the source it injects in terms of namespacing and actual code still looks to be built with a While the generated code might not be in the repository isn't necessarily bad (its great in theory for PRs and general repository size), I actually thought source generators were more like a new paradigm in source generation whereas it seems to just be a new way to hook code into compilation without files. I imagine when dealing with compilation issues, source generator ones may be a lot harder to debug vs file-generated source (like we do now) as we likely can't see the full "generated" source to see our errors more obviously (sometimes error messages from compilation aren't the most intuitive). Hopefully there are some more examples in the future where source generators are used that our workflow seems more suited for. |
PronounceableText-to-stringSchemaClass- no longer allocates an array per call toIsPrimitiveCloses #126