Closed rvuistin closed 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?
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
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.
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.
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.
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.