mamift / LinqToXsdCore

LinqToXsd ported to .NET Core (targets .NET Standard 2 for generated code and .NET Core 3.1, .NET 5+ for the code generator CLI tool).
Microsoft Public License
41 stars 15 forks source link

Export root object from XRoot and XRootNamespace. #12

Closed rvuistin closed 4 years ago

rvuistin commented 4 years ago

Avoid checking all of the typed elements for nullity when you just need the non-null one. Please update the TypesThatInheritFromXTypedElementTest unit test to take in account this modif.

mamift commented 4 years ago

Avoid checking all of the typed elements for nullity when you just need the non-null one.

Would you mind clarifying what you mean by that? "Avoid checking for nullity when you just need the non-null one?" How do I know which one is not null is I do not check for nullity?

rvuistin commented 4 years ago

Actually, the XRoot class (or the XRootNamespace) declares one read-only property (and one constructor) per element.

Assume you get an instance of it with one of the Load method. If everything goes well, the rootObject is non-null and all but one element properties return null, right?

In my case I just need an instance of the base class (XTypedElement) that is the rootObject. I would like not to have to test all of the element properties to find this value.

I added a public property (Root) that exports the rootObject field.

Sorry for my english, my mother tongue being french

mamift commented 4 years ago

OK I understand what you've written; your English is good and I think I understand what you're trying to say.

But I was referring to your remarks on the TypesThatInheritFromXTypedElementTest unit test. What does that unit test have to do with this pull request? All the existing tests passed, so I see no issue if I merged this PR, and I don't see the need to modify that unit test.

rvuistin commented 4 years ago

If we add any member to any class, here the Root property to the XRoot and XRootNamespace classes, the asserts concerning members.Count and propertyMembers.Count in this unit test should fail.

mamift commented 4 years ago

Ah OK. I just realised you cannot see the build pipeline I've setup to automatically run checks on pull requests and pushed commits; this change of yours passed all those tests anyway.