question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeCollection's IsEmpty will alway be false

See original GitHub issue

Description

The IsEmpty property in AttributeCollection will always be false, because the _data is never been null

As the Constructor code says, we will set the _data field a not null value

https://github.com/OfficeDev/Open-XML-SDK/blob/0977a9430407115ff9ed149f60496fbb2688b5e5/src/DocumentFormat.OpenXml/Framework/Metadata/AttributeCollection.cs#L15-L27

And the IsEmpty property will be false only when the _data is null

https://github.com/OfficeDev/Open-XML-SDK/blob/0977a9430407115ff9ed149f60496fbb2688b5e5/src/DocumentFormat.OpenXml/Framework/Metadata/AttributeCollection.cs#L29

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lindexicommented, Jul 23, 2020

@twsouthwick Thank you. It is not null.

Why it is not null? Because we use the DocumentFormat.OpenXml.Framework.ReadOnlyArray to cast the null array to ReadOnlyArray object.

    public static implicit operator ReadOnlyArray<T>(T[] array) => new ReadOnlyArray<T>(array);

That means the ElementMetadata will never receive the null attributes argument

1reaction
twsouthwickcommented, Jul 23, 2020

Do you have a repro of a null red? The readonly array is a custom type that gracefully handles null. If you have a repro, that would be very helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does java.util.List.isEmpty() check if the list itself is null?
The method isEmpty() returns true, if an ArrayList object contains no elements; false otherwise (for that the List must first be ...
Read more >
How to Check if an Object is Empty in JavaScript – JS Java ...
An object is a collection of related data stored as key-value pairs. ... is empty, it will return true , otherwise, it will...
Read more >
AttributeValue of type L does not set IsLSet to true when ...
The problem with this is that the result of GetIsSet will always be false for an empty list (unless that list is an...
Read more >
Blank, Coalesce, IsBlank, and IsEmpty functions in Power ...
Any property or calculated value in Power Apps can be blank. For example, a Boolean value normally has one of two values: true...
Read more >
Is it better to return NULL or empty values from functions ...
Depends on your team consensus: in the case of mine, we agreed to return null for method that returns a single object indicating...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found