Prevent unhandled exception when FieldsPopupElement.Fields list is empty #520
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: none
Description:
When using a popup view with a feature layer that does not have any attributes (e.g. point has no default attributes), a
System.ArgumentException
can occur in theFieldPopupElementView.RefreshTable()
method (see image below for exception details). This PR introduces a check to see if theFieldsPopupElement.Fields
list is empty and, if the list is empty, results in the content being set to null and the method returning. This prevents the exception occuring.Summary of issue:
In the
FieldPopupElementView.RefreshTable()
method:i
is initialised with a value of0
(link to code).i
is increased in a loop that progresses up to the number ofLabels
orFormattedValues
.Fields
, I believe there can be noLabels
orFormattedValues
, so the value ofi
stays as0
.Grid.SetRowSpan(verticalDivider, i);
(link to code) causes the exception becausei
is 0.