V3042. Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the same object.
V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the Element object Xamarin.Forms.Platform.WinRT MasterDetailPageRenderer.cs 288
void UpdateTitle()
{
if (Element?.Detail == null)
return;
((ITitleProvider)this).Title =
(Element.Detail as NavigationPage)
?.CurrentPage?.Title ?? Element.Title
?? Element?.Title;
}
V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'sym' object SymbolStore.cs 56
private static void InsertChildNoGrow(Symbol child)
{
....
while (sym?.nextSameName != null)
{
sym = sym.nextSameName;
}
Debug.Assert(sym != null && sym.nextSameName == null);
sym.nextSameName = child; // <=
....
}
V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'property' object JsonClassInfo.AddProperty.cs 179
internal JsonPropertyInfo CreatePolymorphicProperty(....)
{
JsonPropertyInfo runtimeProperty
= CreateProperty(property.DeclaredPropertyType, // <=
runtimePropertyType,
property.ImplementedPropertyType, // <=
property?.PropertyInfo, // <=
Type,
options);
....
}
V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'imageAndOsType' object VirtualMachineScaleSetStrategy.cs 81
internal static ResourceConfig<VirtualMachineScaleSet>
CreateVirtualMachineScaleSetConfig(...., ImageAndOsType imageAndOsType, ....)
{
....
VirtualMachineProfile = new VirtualMachineScaleSetVMProfile
{
OsProfile = new VirtualMachineScaleSetOSProfile
{
....,
WindowsConfiguration =
imageAndOsType.CreateWindowsConfiguration(), // <=
....,
},
StorageProfile = new VirtualMachineScaleSetStorageProfile
{
ImageReference = imageAndOsType?.Image, // <=
DataDisks = DataDiskStrategy.CreateVmssDataDisks(
imageAndOsType?.DataDiskLuns, dataDisks) // <=
},
},
....
}
V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'existingContacts' object RemoveAzureKeyVaultCertificateContact.cs 123
public override void ExecuteCmdlet()
{
....
List<PSKeyVaultCertificateContact> existingContacts;
try
{
existingContacts = this.DataServiceClient.
GetCertificateContacts(VaultName)?.ToList();
}
catch (KeyVaultErrorException exception)
{
....
existingContacts = null;
}
foreach (var email in EmailAddress)
{
existingContacts.RemoveAll(....); // <=
}
....
}
V3042 [CWE-476] Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'val.NewValue' object TournamentTeam.cs 41
public TournamentTeam()
{
Acronym.ValueChanged += val =>
{
if (....)
FlagName.Value = val.NewValue.Length >= 2 // <=
? val.NewValue?.Substring(0, 2).ToUpper()
: string.Empty;
};
....
}
Similar errors can be found in some other places:
V3042 [CWE-476] Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'api' object SetupScreen.cs 77
private void reload()
{
....
new ActionableInfo
{
Label = "Current User",
ButtonText = "Change Login",
Action = () =>
{
api.Logout(); // <=
....
},
Value = api?.LocalUser.Value.Username,
....
},
....
}
This is exactly the case when a reply to a comment turned into a small blog post. The power of ...