squid808 / gShell

PowerShell Cmdlets and .Net Libraries for Google Apps and Gmail APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Functions that have a SelectMany in the LINQ query need a null check

NullReferenceError opened this issue · comments

Functions like "Get-GDriveComment", "Get-GAGroup" or "Get-GAGroupMember" should have some kind of null check to prevent the enumeration from returning a null reference exception when ToList is run on the result set. Create an empty group and call "Get-GAGroupMember" to recreate this issue.

IE, For Get-GAGroupMember:

WriteObject(members.List(GroupName, properties, StandardQueryParams: StandardQueryParams).Where(x => x.MembersValue != null).SelectMany(x => x.MembersValue).ToList());

This fix prevents the error from being thrown, but not sure if the empty result set should be something else:

NullReferenceError@d4286b9